Advertisement

Slow Blending in Fullscreen mode

Started by February 22, 2005 10:40 PM
4 comments, last by Mastadex 20 years ago
I think the title speaks for itself. My applications slows to a crawl when i run it in full screen mode instead of windowed. I read up on this topic and saw that it was a common issue. Is there a work around for this? What im doing is setting the alpha channel using: SDL_SetAlpha(i, SDL_SRCALPHA | SDL_RLEACCEL, a); and then drawing it to make a 'fading' effect. works great in windowed mode. I tried playing around with different flags, removing some adding others, didnt help. Any Suggestions?
It's been a while since I did some serious work with SDL, but i recall having the same problems.. I think it's alpha blending that causes those problems, because there's no hardware supported alpha blending..

I'm guessing that in windowed mode your surfaces are being created in "system memory" where in fullscreen they are in video memory (on the graphics card), and since no hw alpha support, it has to get the surface from gpu, blend it in ram, send it back to gpu.. a performance killer operation :)

You could try giving SDL_SWSURFACE flag when you call SetVideoMode, this will make your backbuffer in system ram instead on the graphics card, but i'm not sure if loading surfaces via SDL_LoadBMP will put them in the proper place, so you can make sure by a simple check:

if(mysurf->flags & SDL_SWSURFACE) // yay!
else // nay

if nay, you can use SDL_ConvertSurface to convert it to the same pixel format as your display mode (which also improves performance if they aren't the same) and also give it SDL_SWSURFACE flag to put it in the right place.. SDL_DisplayFormat/DisplayFormatAlpha may also do the trick, since it uses ConvertSurface internaly, but i'm not sure on that.

I may be off here, because it's been a while and I tried lots of things to get everything working smoothly..
Advertisement
I think you should not use SDL_RLEACCEL on a surface you are continually changing.

Form the SDL Docs:
Quote:

If flag is OR'd with SDL_RLEACCEL then the surface will be draw using RLE acceleration when drawn with SDL_BlitSurface. The surface will actually be encoded for RLE acceleration the first time SDL_BlitSurface or SDL_DisplayFormat is called on the surface.

paramecij is right, using a hardware surface will cause a major performance hit. The most obvious solution, using a software surface, will increase speed a bit but is usually still inadequete. The solution I played about with before moving to OpenGL was glSDL, it gave me a huge speed boost, the problem was (amongst other things) you can't blit surface-to-surface.
the rug - funpowered.com
As an alternative, you could draw alpha rectangle over the full screen and then blend it down to full alpha. You could use the rectangleRGBA function from the SDL_gfx library. If you're using Dev-C++ and want to use a DevPak to install it, I made one: SDL_gfx DevPak.
Rob Loach [Website] [Projects] [Contact]
I have played around with the flags and I did run everything in pure software mode without touching the video card's memory at all. the performance was about the same. I removed RLEACCEL and the performance was still the same. I do not want to change libraries at this point because I have invested heavily in SDL in this project (since its for school). What I might end up doing is either running it in windowed mode or im going to severely limit the amount of alpha blending im doing. Fading two surfaces is probably the first thing to go. I also use PNG files by using SDL_Image library and im using it along side the alpha channel on PNG images. I just hope that those images will not slow down animation.

If anyone has any information about how to increase speed in _ANY_ way possible, im open to suggestions.


Ill look into converting the format for surfaces.

This topic is closed to new replies.

Advertisement