Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Mar 20, 2019 6:53 pm

All times are UTC




Post new topic  Reply to topic  [ 60 posts ]  Go to page 1 2 3 Next
Author Message
PostPosted: Tue Jun 24, 2008 10:39 am 
Offline
Engineer
Engineer

Joined: Fri Sep 17, 2004 3:15 am
Posts: 86
Here comes a hardware-assisted OpenGL blitter for OpenTTD!
Why not hardware-'accelerated' you say? Because it's not necessarily faster 8)
Remember to disable VSync if you want to fast-forward beyond 60fps, and do not force texture AA since it'll blow up color indexes ...

And please notice, don't press the full-screen key like Alt+Enter, and don't choose prebaked resolution from options window, they simply don't work (yet) ...

Currently it supports Win32 platform, and those platforms with SDL OpenGL support.
(well SmatZ told me he successfully wine openttd.exe under Linux for this one :mrgreen: )

It needs multiple draw buffer and fragment program (pixel shader) support to correctly draw colored text, re-colored buildings, company colors, etc. Which means you must have at least NVIDIA GeForce 6100, ATI Radeon 9550 or Intel GMA X3100 to fully utilize it.

==========
CHANGE LOG

EDIT7:
Fixed a bug that sometimes cause repeatedly encoding of PNG sprites, possibly eat up all available memory ...
For binary please refer to my Patch Pack.

EDIT6: Updated the patch so that MinGW/Cygwin users can build it correctly. Also it won't compile OpenGL stuff anymore while OpenGL is not enabled. Bugfix in SDLGL driver too.
The OpenGL blitter itself isn't changed much however. I was trying MSAA but didn't get very pleasant results yet ...

EDIT5: Updated the patch to include SDL OpenGL video driver hacked by ccfreak2k :mrgreen: And also supported MinGW/Cygwin compiling. Just run ./configure with '--with-win32gl' or '--with-sdlgl' (or both) then 'make' as usual. Linux/Mac users please test if SDLGL driver works on your machines! And ... anyone wish to hack a OSX native OpenGL driver for us? :oops:

EDIT4: This version should do pretty well on both ATI/NV cards. And you could even try it on Intel 915/945 integrated graphics (but without palette animation ...)
ENJOY IT! :mrgreen:

EDIT3: ATI users please try the new binary and report if it displays anything. Be sure to disable force mipmap, texture anti-aliasing to get a pretty screen.

EDIT2: With ccfreak2k's help I've identified some potential fix to make it (partially) work in ATI cards, but by no means perfect. I'll update the patch once I got (at least) map panning works on a capable ATI card.

EDIT: bokkie reported that it DOES NOT WORK on ATI X1950PRO, and ccfreak2k reported it DOES NOT WORK on ATI X850XT either. Perhaps anything using ATI graphics chips have some degrees of problem ...
Since I don't have PCs with capable ATI cards nearby, any debugging assistances are welcomed. (Perhaps I did something strange with shaders?).

==========
You can run this little program to see if your system have needed extensions. (notice: it's a console/text mode program)

Attachment:
File comment: Extension checker
ext-check.zip [172.51 KiB]
Downloaded 560 times


If your system doesn't have needed extensions, it's better to stick with 32bpp-anim/32bpp-optimized blitter until you decided to upgrade your system/graphics card :wink:

Perhaps I will modify it later, so Intel 915G can at least display remapped colors correctly, but I'm gonna 'play' OTTD now :)

==========
You should use the supplied openttd.cfg or put these two lines in yours, to enable OpenGL blitter. You can also adjust the opacity of transparent objects (buildings) between 0-255, smaller values are more transparent, larger values will yield a more 'solid' black shadow.

Code:
videodriver = win32gl
blitter = opengl
transparent_opacity = 64

You can also start openttd.exe with

Code:
-v win32gl -b opengl

And since it's a 32-bit blitter, I strongly recommends to use a TrueType font with anti-aliasing enabled!

Code:
medium_font = Arial
medium_size = 11
medium_aa = true

If you need Chinese/Japanese/Korean support, and you got MS Office installed, you can try 'Arial Unicode MS'. It works great too.

==========
If you want to compile it yourself, you'll need GLee (GL Easy Extension) library from http://elf-stone.com/glee.php. Extract GLee.c/GLee.h and put them in 'src' directory.

'opengl' blitter is platform-independent, with help from 'win32gl' video driver, which is hacked from 'win32' video driver, to do Windows-specific OpenGL initialization, and usual environment/input management. In theory we just need other platform-specific drivers to do OpenGL initialization and management, to use 'opengl' blitter on these platforms.


Attachments:
opengl-080711_r13691.patch [144.38 KiB]
Downloaded 566 times

_________________
I may implement/fix/tweak/eat/ditch it soon (or in distant future, if at all, so don't hold your breath).
If anyone want to be the one please implement it for us all 8)


Last edited by Tiberius on Fri Jul 11, 2008 3:12 pm, edited 21 times in total.
Top
   
PostPosted: Tue Jun 24, 2008 10:52 am 
Offline
Route Supervisor
Route Supervisor

Joined: Mon Apr 02, 2007 8:13 pm
Posts: 399
Location: Nørup, Denmark
This sounds interesting :)

Being a complete noob when it comes to this kind of stuff, makes me wonder why it is desireable.
Is it faster? pretty? geeky?

_________________
Code:
if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}


Top
   
PostPosted: Tue Jun 24, 2008 11:03 am 
Offline
Engineer
Engineer

Joined: Fri Sep 17, 2004 3:15 am
Posts: 86
Fixed case-sensitivity problems in the patch file.

kaan wrote:
Being a complete noob when it comes to this kind of stuff, makes me wonder why it is desireable.
Is it faster? pretty? geeky?

Whether it's faster or not, depends on your system, graphics board etc.
(my C2D@2400 + NV 7600GT does 700fps with 32bpp + animated palette in a new game, so it's indeed faster :mrgreen: )

It's not 'prettier' than existing blitter for now, but it will be easier to do e.g. zooming, transparency effects in OpenGL later. However since we have to keep support original blitters, I don't think there will be many improvements here.

So in conclusion, yes, it's 'geeky' for now :D

_________________
I may implement/fix/tweak/eat/ditch it soon (or in distant future, if at all, so don't hold your breath).
If anyone want to be the one please implement it for us all 8)


Top
   
PostPosted: Tue Jun 24, 2008 11:22 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 07, 2008 6:29 pm
Posts: 1872
Location: Czech Republic
Sounds great! This has awesome potential, especially when I see your FPS. My OTTD is with 8bpp laggy once there are several hundred trains and the map is zoomed out. I hope this will bring vast improvement on my Athlon XP 2500+ with GF 6200 GE. Gonna try it now!

EDIT: The speedup against default 8bpp blitter is brutal. How can I turn on FPS label?

But I see one downside: most graphics don't look very well when zoomed out, especially temperate terrain and maglev tracks look quite weird. The default downsizing algorythm seems to work better for OTTD gfx.


Attachments:
File comment: With OpenGL
Führer's Travel Corp., 18. zář 2263.png [686.97 KiB]
Downloaded 872 times
File comment: 8bpp blitter
Führer's Travel Corp., 18th Sep 2263.png [425.51 KiB]
Downloaded 714 times


Last edited by CommanderZ on Tue Jun 24, 2008 11:46 am, edited 1 time in total.
Top
   
PostPosted: Tue Jun 24, 2008 11:41 am 
Offline
Engineer
Engineer

Joined: Fri Sep 17, 2004 3:15 am
Posts: 86
Apparently the bottleneck of OTTD is not at blitter, and FPS is greatly affected by 'visible sprite count'.
I think it's quite reasonable since OTTD Z-sorts sprites itself before sending them to blitter, and do many redraws assuming blitter don't have Z-testing functionality (yeah! after all they're 2D 'blitters')

I tested with #openttdcoop Public Server Game 96 extensively when implementing it, and the performance on my computer FYI:

C2D @ 2400MHz, NVIDIA 7600GT

(window size 1024x768)
zoomed in: ~230fps
zoomed out 1 level: ~180fps
zoomed out 2 levels:~120fps
zoomed out 3 levels: ~20fps (!)

(window size 1680x1050)
zoomed in: ~130fps
zoomed out 1 level: ~120fps
zoomed out 2 levels:~60fps
zoomed out 3 levels: ~15fps

_________________
I may implement/fix/tweak/eat/ditch it soon (or in distant future, if at all, so don't hold your breath).
If anyone want to be the one please implement it for us all 8)


Top
   
PostPosted: Tue Jun 24, 2008 12:23 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Mon Feb 06, 2006 11:58 pm
Posts: 340
Hmm, somehow my fps are capped at 96 FPS. (measuring with FRAPS)
VSync is "Forced Off" in NV-ControlPanel. (my monitor usually runs at 72Hz)

I remember the VSync options for openGL were on a special openGL menu within the ControlPanel.
Could this be my problem, and is this still the case for 175.19 drivers?

_________________
Copy & Paste Patch for OTTD
Distant-Joined Stations Patch for OTTD
Eyecandy Patch for OTTD


Top
   
PostPosted: Tue Jun 24, 2008 12:36 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Fri Jan 19, 2007 7:26 pm
Posts: 326
Sounds nice, I'm gonna try it. Is it possible to make zoom-out look like in this thread: viewtopic.php?f=33&t=35311&hilit=blitter ? I'd guess it is, it looks much better than the original behavior but in the patch in the mentioned thread zooming in/out takes a sec, which maybe could be faster when using the graphics card.

EDIT: it doesn't seem to work on my ATI Radeon x1950pro... the check says it should work, but I only get a black window (sound is playing) with a fps counter (comes with Ati Tray Tools). I used your build.


Top
   
PostPosted: Tue Jun 24, 2008 1:51 pm 
Offline
Engineer
Engineer

Joined: Fri Sep 17, 2004 3:15 am
Posts: 86
CommanderZ, bokkie:
I'll look into the zooming issue. Currently I'm using nearest neighborhood (no interpolation) since I like original 'blocky' (O)TT(D) feel, and I think original blitter didn't really do nearest neighborhood. (I think these white-blue strips along your tracks are fences rendered!)

Another reason I didn't do interpolation is that ... palette indexes can't be 'interpolated' at all. I used fragment program to do palette lookup/animation, so I must preserve exact color indexes or the screen will become a mess.

This is also the reason I can't "hide" palette-animated pixels when transparency is enabled. But personally I really like the effect of this "bug". :)

==
CommanderZ:
Fraps is your friend :mrgreen:

==
Frostregen:
How about the fast-forward button?
I think the "Force VSync Off" in NV Control Panel is enough. I'm currently away from my testing desktop, so I'll check my driver version later.

==
bookie:
Go for a NVIDIA GeForce 6200+ card ... 8)
Well just kidding. I don't have PCs with capable ATI cards nearby, therefore I can't check the situation nor provide help ... sorry for that :(

_________________
I may implement/fix/tweak/eat/ditch it soon (or in distant future, if at all, so don't hold your breath).
If anyone want to be the one please implement it for us all 8)


Top
   
PostPosted: Tue Jun 24, 2008 4:31 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 07, 2008 6:29 pm
Posts: 1872
Location: Czech Republic
I tried to change the font to Calibri (I love that one!) and it looked fantastic, but as the font has slightly smaller letters than usual, I tried to increase the font to 12. And all texts in the game became unreadable (I can post screenshot) - the game displays just some block blurry things.


Top
   
PostPosted: Tue Jun 24, 2008 5:06 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Mon Feb 06, 2006 11:58 pm
Posts: 340
Oh my... fast forward... ;)

thx... will test later at home

_________________
Copy & Paste Patch for OTTD

Distant-Joined Stations Patch for OTTD

Eyecandy Patch for OTTD


Top
   
PostPosted: Tue Jun 24, 2008 8:18 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Thu Oct 28, 2004 4:42 am
Posts: 703
Location: Catch the Fox if you can... 15 years and counting!
bokkie wrote:
Sounds nice, I'm gonna try it. Is it possible to make zoom-out look like in this thread: viewtopic.php?f=33&t=35311&hilit=blitter ? I'd guess it is, it looks much better than the original behavior but in the patch in the mentioned thread zooming in/out takes a sec, which maybe could be faster when using the graphics card.

EDIT: it doesn't seem to work on my ATI Radeon x1950pro... the check says it should work, but I only get a black window (sound is playing) with a fps counter (comes with Ati Tray Tools). I used your build.


Yes, just tried a Radeon 9800XT and also had that black window .. :?


Top
   
PostPosted: Tue Jun 24, 2008 9:00 pm 
Offline
Engineer
Engineer

Joined: Fri Sep 17, 2004 3:15 am
Posts: 86
Updated the first post to clarify some status about ATI graphics card support.

More about zooming out quality: This blitter utilizes texture atlas to increase batch size, so mip-mapping will be a little difficult. I already have some thoughts about this, but don't have time to implement it right now, so please be patient ... :oops:

_________________
I may implement/fix/tweak/eat/ditch it soon (or in distant future, if at all, so don't hold your breath).
If anyone want to be the one please implement it for us all 8)


Top
   
PostPosted: Tue Jun 24, 2008 10:51 pm 
Offline
Engineer
Engineer

Joined: Mon Mar 08, 2004 9:14 pm
Posts: 52
Location: Sunderland UK
this also shows a black screen on the RADEON 9550.


Top
   
PostPosted: Wed Jun 25, 2008 6:48 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Wed Mar 30, 2005 9:43 am
Posts: 1588
Generating mipmaps would help the zoom-out issue.

_________________
He's like, some kind of OpenTTD developer.


Top
   
PostPosted: Wed Jun 25, 2008 9:29 am 
Offline
Engineer
Engineer

Joined: Sun Mar 12, 2006 2:43 pm
Posts: 1
Location: Naumburg (S.) (Germany)
On my Ati 3870, the screen keeps black too.


Top
   
PostPosted: Wed Jun 25, 2008 10:41 am 
Offline
Engineer
Engineer

Joined: Tue May 08, 2007 8:46 pm
Posts: 18
Location: Germany, Dresden
Hehe, thats cool 8)
How about anti aliasing?


Top
   
PostPosted: Wed Jun 25, 2008 10:46 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 07, 2008 6:29 pm
Posts: 1872
Location: Czech Republic
Quote:
I tested with #openttdcoop Public Server Game 96 extensively when implementing it, and the performance on my computer FYI:

C2D @ 2400MHz, NVIDIA 7600GT

(window size 1024x768)
zoomed in: ~230fps
zoomed out 1 level: ~180fps
zoomed out 2 levels:~120fps
zoomed out 3 levels: ~20fps (!)

(window size 1680x1050)
zoomed in: ~130fps
zoomed out 1 level: ~120fps
zoomed out 2 levels:~60fps
zoomed out 3 levels: ~15fps


My stats: 1280*1024 on GF 6200, Athlon XP 2500+ (single core 32 bit), 1500 MB RAM

Tested on the same map
zoomed in: ~25 fps
l1 zoom out: ~19 fps
l2 zoom out: ~16 fps
l3 zoom out: ~9 fps

Sadly no Fraps with no-opengl blitters :(


Top
   
PostPosted: Wed Jun 25, 2008 11:08 pm 
Offline
Engineer
Engineer

Joined: Wed Jun 25, 2008 11:01 pm
Posts: 9
Location: California, United States
This post intentionally left blank.


Last edited by ccfreak2k on Thu Jun 26, 2008 2:26 pm, edited 3 times in total.

Top
   
PostPosted: Wed Jun 25, 2008 11:25 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Thu Oct 28, 2004 4:42 am
Posts: 703
Location: Catch the Fox if you can... 15 years and counting!
Here you go..

Tested on a Radeon 9800XT 256MB

Windows XP SP2

Hope it helps :mrgreen:


Attachments:
File comment: Command line!
Command.PNG
Command.PNG [ 11.28 KiB | Viewed 18419 times ]
File comment: How Intro looks!
Intro.PNG
Intro.PNG [ 206.95 KiB | Viewed 18466 times ]
Top
   
PostPosted: Wed Jun 25, 2008 11:46 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Thu Oct 28, 2004 4:42 am
Posts: 703
Location: Catch the Fox if you can... 15 years and counting!
And this one from a Notebook with a Radeon 9600 64MB Mobility :)


Attachments:
File comment: Command line!
Command.PNG
Command.PNG [ 10.28 KiB | Viewed 18443 times ]
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 60 posts ]  Go to page 1 2 3 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.