The speed problem is definetly in SDL_UpdateRects. My graphics card
doesn’t support SDL’s DoubleBuffer so I will have to add native double
buffer support back to powerpak, but that will be just as slow because I
will have to call update rects. I even tried a memcpy directly to
screen->pixels and still have to call SDL_UpdateRects. Isn’t there
anyway at all to directly access the screen and still have the features
The best you’ll be able to do is passing SDL_HWSURFACE to SDL_SetVideoMode().
On systems that support it (DirectX, X11/DGA) you’ll get direct access to
video memory. This is not a limitation of SDL, as much as a limitation of
the underlying driver capabilities.
I don’t know how to support multiple depths and alpha values and
stuff so it is not at all feasible for me to write it all over from
If you need to convert from a pixel format you expect, you need to
draw to an internal buffer and convert that to the video format.
There’s no way around that. SDL provides this transparently, but
if you pass SDL_ANYFORMAT in the flags to SDL_SetVideoMode(), SDL
will not perform any conversions, it will give you the closest
depth supported by the underlying driver.
I realize that a dirty rectangles type situation would greatly
speed things up, but there are engines (tile based, voxel graphics, 3d
graphics) that have to update the entire screen everytime and being
stuck in a 27fps framerate with a 400mhz isn’t very good.
Unfortunately, until Linux has direct hardware acceleration, you’ll
have to live with it. 27 fps sounds a little slow, but you probably
won’t get more than 30-40 FPS on PentiumII 350 MHz class systems.
Doesn’t CivCTP use SDL? How come that is so fast on my computer (Yes, I
know you can’t reveal that Sam :)) Actually I guess I know the answer
Civ doesn’t need to update the whole screen until scrolling time comes
around. Still CivCTP’s isometric engine scrolls ten times faster than my
simple square tile based implementation. Dos Loki use a 'suped up’
version of SDL?
Nope, it uses stock SDL. If you look closely, you’ll see that the
framerate isn’t really that high, but it scrolls in large jumps.
There are all sorts of techniques to get around low framerate.
Does anybody have any examples of a doublebuffer implementation in SDL?
If I get a chance, I’ll whip up an example.
All I want to to have people stop insulting that which have have
practically dedicated the past 2 and half months of my live to.
I know the feeling.
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec