Well, this is a VFAQ. (It’s probably about time to put this
information on a web site with some code examples and stuff… Or is
there one that I don’t know of?)
Anyway, you’re not really making a mistake. You’ve just hit the
"modern PCs are not designed for software rendering" brick wall.
The problem is that CPU access to VRAM is very slow on modern video
cards. As if that isn’t bad enough, reads are insanely slow; many
times slower than writes. And alpha blending happens to be a
read-modify-write operation…
What you’re really supposed to do is upload your graphics to the
video card and then use the 3D accerator for rendering. That is,
OpenGL or Direct3D, which is what modern hardware is designed for.
The major advantages are that this runs insanely fast on any
reasonably modern hardware, and that you get filtered scaling,
rotation, color modulation, blending and stuff with no significant
performance impact.
However, using 3D acceleration means your game won’t run without 3D
drivers and libs, and without a 3D accelerator, you may actually see
even worse frame rates than you get now. So, this is not an option
unless it’s otherwise motivated to add “3D accelerator with OpenGL
and/or Direct3D drivers” to the minimun system requirements.
There is a simple trick, though: Render into a software shadow
surface, copy (plain blit) to the display surface and then flip.
Repeat for each frame. (Note that if you get a s/w display surface
from SDL, you should not set up a shadow surface of your own. That
would just be a waste of memory and cycles.)
That way, you get fast s/w rendering with alpha and stuff, but you
still perform only writes to VRAM. The primary advantages are that
this works everywhere, and that you can implement your own low level
s/w blitting routines for pixel level effects. (You can do that
with OpenGL and Direct3D, but you can’t do things the same way, and
it still has major performance issues on most systems.)
//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 Friday 02 April 2004 07.55, Romulo Gnomo wrote:
I?m having some trouble with Fullscreen mode. I?m
quite new to SDL so don?t mind if it?s a stupid
question. Some people told me a stupid question is
only an unquestioned question. So I decided to post
this.
My code works allright in windowed mode, but when I
try to run it on fullscreen mode it gets completely
slow! It?s too slow, something like less than 1fps.
that really sucks.
The problem happens only when I try to use alpha
blending and if the colordepth of the loaded images is
different than that of the screen. Did I forget
Something in the code?
Something tells me it?s a common starters mistake.