Sign in to follow this  

glDrawBuffer(GL_FRONT) leads to screen corruption/driver crash

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a strange problem: My app uses glDrawBuffer(GL_FRONT) to paint its menus and glDrawBuffer(GL_BACK) to render the game stuff. The app uses SDL and calls SDL_SetVideoMode() to toggle full screen. Now when I am toggling from windowed to fullscreen mode and back while in the game, and then return to menu mode, calling glDrawBuffer(GL_FRONT) leads to the screen being completely corrupted (actually it looks like the front buffer is still in full screen mode). How can I fix this? [Edited by - karx11erx on December 19, 2005 4:35:37 PM]

Share this post


Link to post
Share on other sites
That seems very strange usage to me. It would mean that the menus are always a frame behind your game scenes, when you call glSwapBuffers.
Why not just overlay the menu on the game scene?

Share this post


Link to post
Share on other sites
Hi Bluntman,

the app isn't always running a game, so there's not always a game scene to render behind the menu. And obviously, the app uses glFlush() when in menu mode. But when turning fullscreen on and off while in game, the screen stays corrupted even after having left the screen.

As I said, it somehow looks like the OpenGL window pos and size (or whatever) don't get set properly for the front buffer.

Share this post


Link to post
Share on other sites
Quote:
Original post by karx11erx
Hi Bluntman,

the app isn't always running a game, so there's not always a game scene to render behind the menu.


So? You just render in the back buffer the game scene, if exists, on top of that the menu and then you flip the buffers. That's how double buffering works.

if (GameRunning) RenderGameScene();else glClearColor(GL_COLOR_BUFFER_BIT);
Enter2DMode();
RenderMenu();
Leave2DMode();
SDL_GLSwapBuffers();

I've never seen anyone using double buffering like you do. It's crazy.

Share this post


Link to post
Share on other sites
It works like the following:

If (mode == menu) {
glDrawBuffer (GL_FRONT);
//render the menu
glFlush ();
}
else {
glDrawBuffer (GL_BACK);
// render game frame
SDL_GL_SwapBuffers ();
}

I didn't create that part of the app (D2X port of Descent 2), btw.

Share this post


Link to post
Share on other sites
I have now changed the rendering code to always render to the back buffer and swap buffers after rendering. The problem persists: If I switch to full screen and back to windowed mode via SDL functions, whenever I call an OpenGL function that receives a GL_FRONT parameter, the screen gets garbled. This time it is glReadBuffer (GL_FRONT) before a call to glReadPixels().

Sigh.

Share this post


Link to post
Share on other sites
Everytime you call SDL_SetVideoMode, the current GL context is destroyed and a new is created. That way, you loose everything: buffers,colors,textures,lists...
You must initialize everything from the beginning, and of course you can't expect the front buffer contents to be valid unless you have written to it after the call to SDL_SetVideoMode.

Share this post


Link to post
Share on other sites
mikeman,

when I toggle fullscreen in-game and subsequently return to the menu, buffers get rendered and switched tens of dozens of times at least (with 150 fps). The strange thing is that exactly the call to glDrawBuffer (GL_FRONT) or glReadBuffer (GL_FRONT) garbles the screen - continuing to play the game works fine after a fullscreen toggle. Also, if I just toggle fullscreen once (lets say windowed -> fullscreen), everything continues to work. Only after toggling back the problem appears.

Btw, my app *does* reload all textures, shaders, framebuffers and what not after toggling fullscreen.

If this problem does have something to do with doing something on an invalid/non-existant OpenGL context, I just cannot figure what.

Share this post


Link to post
Share on other sites
I have now completely recoded the application to generally use double buffering. On NVidia gfx hardware, I now get a NULL pointer when toggling from windowed to fullscreen and back ... ??? :(

Share this post


Link to post
Share on other sites

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this