🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL Blurring effect causing grief

Started by
13 comments, last by PnP Bios 19 years, 10 months ago
Im trying to come up with a way to blur the screen in SDL, such that when an object moves a faded version of it remains at its last destination briefly. I have attempted this effect by drawing my objects to a buffer, and then drawing this buffer to the screen. The next iteration the buffer is copied and drawn back onto itself, after setting the alpha to 128. This works, however it has proven incredibly slow. I have set hardware acceleration and tried using a colorkey but nothing seems to want to make it faster :oS If anyone can point me in the right direction, I would really appreciate it.
Advertisement
Shoot. I know you are going to hate to hear this, but it might almost be better to use openGL, or I think there is some sort of rewrite available called SxDL, or something like that, that uses pure openGL for all of the rendering.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Darn. Its not too bad, I'm not very far into SDL anyway. Thanks for the advice, can you tell me why it is so slow? Or am I expecting things from it that I probably shouldn't?
It all depends on how big your images are, and whether or they are hardware or software surfaces. Also, it is a good idea to make sure that all of your surfaces have the same bit-depth. It takes some time to recalculate that kind of stuff on the fly. That might be it! make darn sure that everything is the same depth.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Thanks again, I've checked and everything seems to be OK. Right now Im testing alpha blending by blending two images together. I get a completely smooth transition between the two using some crossfading code I found on the net, but it only runs like that in a window. Even if the window is as large as my screen, it is still completely smooth. As soon as I set full screen mode... bam, thats it, frame rate needs to be measured in seconds per frame.

Can anyone tell me why there is such a disparity between windowed and full screen performance?
I thought fullscreen was supposed to be faster....
You can do a fake fullscreen by using SDL_NOFRAME. but then you run the risk of it not positioning at the upper left of the screen...

Just out of curiosity, how are you doing your main loop? can you show me how you are calling SDL_SetVideoMode?

Because if it is what I think it is, you may be specifing the wrong color depth.

If you are going to use alpha values, use 32bits, not 16.

What I do is call it like this
screen = SDL_SetVideoMode(x_width, y_height, 0, SDL_DOUBLEBUF|SDL_FULLSCREEN|SDL_HWSURFACE); with leaving the bit field at zero, it uses whatever the desktop uses for a resoultion.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
"SDL_RLEACCEL RLE encoding increases speed when blitting transparent
surfaces set via SDL_SetColorKey ..alot."

try using that flag too.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Probably not the answer you are looking for but it seems you are not alone.

Article
"If you are not willing to try, you will never succeed!"GrellinC++ Game Programming
I just realised setting SDL_SWSURFACE instead of SDL_HWSURFACE in the call to SDL_SetVideoMode makes it a lot faster. I don't understand that at all, surely a hardware surface would be faster? Does this mean that in windowed mode SDL_SWSURFACE is forced? [Edit: I think it must be... someone should write up a common pitfalls of SDL and stick it somewhere visible, I've been kicking myself over this all afternoon! Maybe I'll do something like that when I get further into SDL]

I set the bit depth to 0, so it should use 32bpp, my desktop setting.

Grellin: Thats great, I think I understand why it was so slow now, it was the reading from video memory. Thanks! ++ratings all round
What about MMX?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One

This topic is closed to new replies.

Advertisement