You’ve referenced your pig example a couple times and it is indeed
a good example to look at-- but for an example it really lacks
Yeah. The idea was to write a tutorial or something around it, but I
hardly had enough spare time to hack the code… So, I was in a great
hurry - and no comments are better than incorrect and confusing
Note that there’s a separate text file that describes the dirtyrect
manager, in case you’ve been scratching your head over that code.
I was able to figure out what you were doing, but it
did take me a while. I tried duplicating your process of apparently
blttitng everything onto a buffer then blitting that buffer onto
the screen. The thing is with what I’m currently working on there
can be no update rectangles. It’ll either be everything or nothing
(tile-based scrolling background).
Then you’re lucky, at least in some respects. The algorithm Pig uses
is overkill, and in fact just a waste of cycles, if you have to
repaint the whole screen every frame anyway.
What you do is very simple:
Blit into a shadow buffer;
Blit the shadow buffer to the display surface;
Flip the display surface;
Now, if you want to avoid extra copying on targets that don’t support
h/w display surfaces, just eliminate this part too, and blit directly
to the display surface instead. If the display surface is not a h/w
surface, it’s already a s/w shadow surface, so there’s no point in
adding another one.
Taking that into account my
framerate actually fell by half.
Yeah, that’s the bad news… :-/
That’s why there is glSDL - although that doesn’t really solve the
problem, but allows users with accelerated OpenGL to avoid it.
I’ll try again when I’m on a
different kind of scene where I’d have update rectangles.
As for the transparent blitting problem I have confirmed it.
Exactly the same code except the full screen flag yields different
results. Now I do have a crappy system to work with here
(Geforce2Go), and I’ve tried alternating the surfaces between HW
and SW but it doesn’t seem to make a difference.
Remember that SDL_SWSURFACE == 0, and SDL_DOUBLEBUF pulls in
SDL_HWSURFACE automatically… That is, you have to remove
SDL_DOUBLEBUF to get a s/w surface. (Except when the system can’t
give you a h/w surface, obviously.)
Either way, it could be the pixel format… The shadow surface may get
the same pixel format as the actual display buffer, unless you
specifically ask for something else. Does the display bpp have any
effect on the alpha blending, with and/or without a h/w surface?
Thanks again for your help. I’m keeping your code for reference!
BTW, could you be more specific about what parts of the code are hard
to understand? That would help improve the documentation for the next
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Wednesday 28 April 2004 14.09, Brian wrote: