No double buffer, eh? (solved)

Started by
4 comments, last by randomZ 19 years, 3 months ago
(Using SDL 1.2.5) Attempted to create a double buffered surface. Hardware supports double buffer, however, the surface is not created with the double buffer flags. Can't put two and two together, code snippet:
// declatation
SDL_Surface* g_pMainSurface = NULL;

//function
{

// check to see if we have hardware capabilities, this
// is botched from the SDL documentation (read: may not
// be doing it right). Returns the "We have hardware support.."

	const SDL_VideoInfo* vidcaps = SDL_GetVideoInfo();	
	if (vidcaps->hw_available)
		fprintf(stdout, "\nWe have hardware support!!\n");
	else
		fprintf(stdout, "\nWe have NO HARDWARE SUPPORT ;_;\n");

// actually create the surface. Note that the depth parameter
// doesn't make a difference because of SDL_ANYFORMAT, and that
// SDL_HWSURFACE is indeed ored in there (its a requirement for
// SDL_DOUBLEBUF).

	g_pMainSurface = SDL_SetVideoMode(640, 480, 32, (SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF));

// surface created successfully (I'm able to draw to it); now
// we check to see if it contains the flags I requested. I know
// its not double buffered because the surface isn't clearing
// when I call SDL_Flip.

	if (g_pMainSurface->flags == (SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF))
		fprintf(stdout, "\nEveryhint is working, dammit!");

// and finally, the render loop where I indeed do call SDL_Flip
// instead of SDL_UpdateRect.
        {
			SDL_Flip(g_pMainSurface);
        }
} 

Any ideas? EDIT: Added "solved" to subject. [Edited by - Mushu on January 4, 2005 9:40:26 PM]
Advertisement
Is there a reason that you are trying to use Hardware Double Buffering? I was under the impression that most modern hardware is really lacking in old 2D Graphics capabilities and using Hardware double buffering will just slow your app down. I did some testing on two computers I have access two (both of which SDL says that "Hardware Double Buffering is Available), but they both ran simple test apps at a considerably slower rate than when using Software Surfaces.
Most cards don't run hardware surfaces in windowed mode. Try including the SDL_FULLSCREEN flag as well.

Drew Sikora
Executive Producer
GameDev.net

Quote:Original post by wyrzy
Is there a reason that you are trying to use Hardware Double Buffering?

Quote:SDL Documentation
SDL_DOUBLEBUF Enable hardware double buffering; only valid with SDL_HWSURFACE.

Don't know if that's the way of it, but I'll trust them for now. [wink]
Quote:Original post by GaiidenMost cards don't run hardware surfaces in windowed mode. Try including the SDL_FULLSCREEN flag as well.

Yep. No joy there either.

I actually hacked together a solution that works... recalling from the good old days of DirectX "g_pDev.clear(...)" which would clear the front buffer.

Well, why not clear my front buffer manually? So I decided to do just that:
SDL_FillRect(g_pMainSurface, NULL, 0);

Have no idea why it won't let me have a double buffer (it just doesn't like me!) but hey! This little hack works, and at the resolution I'm making my app endure, it won't cost that much anyway. Yay!

Thanks for the help guys! [grin]
Oh, you never said how not working. If you stated something like image not moving properly or image left behind after drawing next one, that would have helped. As you found out, even with double buffering it doesn't magically clear the screen for you. Double buffering is just so you can draw to the back ground screen while displaying the current. Therefore have "smooth" animation possible.
Quote:Original post by wyrzy
I did some testing on two computers I have access two (both of which SDL says that "Hardware Double Buffering is Available), but they both ran simple test apps at a considerably slower rate than when using Software Surfaces.


This isn't related to double buffering, but to the display surface being in video memory. When alpha blitting to it, SDL has to read from VRAM, which is very slow.

-Sebastian
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/

This topic is closed to new replies.

Advertisement