glDrawBuffer(GL_FRONT) leads to screen corruption/driver crash

Started by
7 comments, last by karx11erx 18 years, 4 months ago
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]
_________karx11erxVisit my Descent site or see my case mod.
Advertisement
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?
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.
_________karx11erxVisit my Descent site or see my case mod.
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.
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.
_________karx11erxVisit my Descent site or see my case mod.
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.
_________karx11erxVisit my Descent site or see my case mod.
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.
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.
_________karx11erxVisit my Descent site or see my case mod.
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 ... ??? :(
_________karx11erxVisit my Descent site or see my case mod.

This topic is closed to new replies.

Advertisement