I have a simple program that blits some surfaces that use
transparency to the screen. I am getting around 700 fps
fullscreen, but the images that are blit’ed, are “flashing”.
If I switch back to softwaremode and not fullscreen, I can get
the fps down to around 15-30 and I do not see the “flashing”
Is the problem the screen is updating too fast? Should I be
using double buffering? Or is that not related to the problem?
I have a simple program that blits some surfaces that use
transparency to the screen. I am getting around 700 fps
fullscreen, but the images that are blit’ed, are “flashing”.
If I switch back to softwaremode and not fullscreen, I can get
the fps down to around 15-30 and I do not see the “flashing”
Is the problem the screen is updating too fast? Should I be
using double buffering?
Yes. If you don’t use double buffering, things might be visible on
screen just after you called the blit, before you use the
SDL_UpdateRects function.
That usually cerates that “blinking” effect you see, since something
half-drawn is shown on screen.
Just add SDL_DOUBLEBUF to these flags.
Btw, SDL_RLEACCEL has no effect on the video surface, it’s only useful
on SDL surfaces.
(SDL_RLEACCEL should be set on the source surface of a blit and if the
blit is done in software, it should accelerate the blit)
Just add SDL_DOUBLEBUF to these flags.
Btw, SDL_RLEACCEL has no effect on the video surface, it’s
only useful
on SDL surfaces.
(SDL_RLEACCEL should be set on the source surface of a blit
and if the
blit is done in software, it should accelerate the blit)
Stephane
Does SDL_RLEACCEL have any negative impact if used on a
surface, even if the screen is in hardware mode?
Is this the correct way to use doublebuffering? It now
averages 70 fps (instead of 600+) but the flashing is gone.
Just add SDL_DOUBLEBUF to these flags.
Btw, SDL_RLEACCEL has no effect on the video surface, it’s
only useful
on SDL surfaces.
(SDL_RLEACCEL should be set on the source surface of a blit
and if the
blit is done in software, it should accelerate the blit)
Stephane
Does SDL_RLEACCEL have any negative impact if used on a
surface, even if the screen is in hardware mode?
If the blit is done by the cpu, SDL_RLEACCEL will probably speed up
the blits (that depends on the proportion of empty pixels and the layout
of the pixels in the surface).
If the screen is a hardware surface and the blits is done in hardware,
the SDL_RLEACCEL flag is ignored.
(notice there is a special case : most backends don’t hardware
accelerate alpha blits, so these are done by the cpu anyway, even if the
screen is a hardware surface. So the first case applies here)
So having a speed increase or not heavily depends on :
your hardware platform (cpu, video card…)
the backend you currently use (and whether it is able to accelerate
colorkey or alpha blits)
whether the video surface is hardware or software
Is this the correct way to use doublebuffering? It now
averages 70 fps (instead of 600+) but the flashing is gone.
//render function
//blit some…
//flip
SDL_Flip(screen);
Yes.
Do I no longer need to use UpdateRect()? It says that if
doublebuffering is not enabled, it will instead call
UpdateRect() from SDL_Flip().
You have to choose between SDL_UpdateRects() and SDL_Flip().
SDL_UpdateRects is meant to be used with single buffered surfaces, while
SDL_Flip is meant to be used with doublebuffered surfaces.
(and if you call the wrong one, SDL will call the correct one for you
anyway)