OpenGL + WinXP SDL_SetVideoMode problem (bug)

Hi,

I’m making a game using SDL with OpenGL and i want to change the video mode
at runtime. So i use SDL_SetVideoMode, but i’ve met bugs with my radeon 7200:

  • If i switch from 32bpp windowed to 16bpp fullscreen my video driver
    always crashes. Well maybe it’s not because of SDL after all :slight_smile:
  • If i switch from 16bpp fullscreen to 32bpp windowed i get a new window
    (sometimes i need to make it appear by iconifying/restoring it) but it
    doesn’t receive any keyboard events anymore (SDL_GetKeyState doesn’t work
    either, but ActiveEvents still work for example). This must be because of SDL.
  • If i toggle double buffering i get the same problem: no keyboard input
    anymore.

I can avoid all those bugs if i don’t use double buffering, but it’s too ugly.
If you want to test that bug just add a SDL_SetVideoMode in testgl.c so
that you first use a single buffer and then you use double buffering
(copy/paste and replace a 1 with a 0). Should be like:

—8<------------8<------------8<------------8<------------8<------------8<----
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 );
if ( fsaa ) {
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
fprintf(stderr, “Couldn’t set GL mode: %s\n”, SDL_GetError());
SDL_Quit();
exit(1);
}
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if ( fsaa ) {
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
fprintf(stderr, “Couldn’t set GL mode: %s\n”, SDL_GetError());
SDL_Quit();
exit(1);
}
—8<------------8<------------8<------------8<------------8<------------8<----

The result is that if you press Esc for example nothing happens. Well at
least on my computer.
I think the problem might be when SDL needs to reset something, like making
a new window or something, which should be rare, i guess.

Thanks in advance for any help.–
Hibernatus

Hibernatus wrote:

I’m making a game using SDL with OpenGL and i want to change the video
mode at runtime. So i use SDL_SetVideoMode, but i’ve met bugs with my
radeon 7200:

Do you remember to set all opengl-state, and upload all onboard data
(textures, VBOs, displaylists etc.) to the new context?

Regards,
\Mikkel Gjoel

Yes, i reload all the textures and i don’t use any display list, vbo, etc.
Everything works fine if i switch from 16bpp windowed to 16bpp fullscreen
for example, or if i don’t use double buffering.
And since there’s a problem with keyboard input it really seems to be a
problem in SDL.
Also the testgl.c example is simple enough to say it shouldn’t be caused by
a misuse of opengl.

At 20:11 16/03/2004 +0100, you wrote:>Hibernatus wrote:

I’m making a game using SDL with OpenGL and i want to change the video
mode at runtime. So i use SDL_SetVideoMode, but i’ve met bugs with my
radeon 7200:

Do you remember to set all opengl-state, and upload all onboard data
(textures, VBOs, displaylists etc.) to the new context?

Regards,
\Mikkel Gjoel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Hibernatus

The result is that if you press Esc for example nothing happens. Well at
least on my computer.
I think the problem might be when SDL needs to reset something, like
making a new window or something, which should be rare, i guess.

WIN_GL_ResetWindow (SDL_wingl.c) is called when the bug occurs.
I don’t know the SDL source well enough (not at all actually) but i guess
you make a new window without updating DirectInput. That would be why
keyboard input doesn’t work anymore.
I don’t remember how DirectInput works but i guess you should at least call
SetCooperativeLevel again since it takes a window handle.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/input/ref/ifaces/idirectinputdevice9/SetCooperativeLevel.asp

Maybe there are other things to update/clean up when you make a new window.–
Hibernatus