SDL 1.2 + SetVideoMode()

My program crash on Windows98 + SDL 1.2 + OpenGL FullScreen
when changing screen size with SDL_SetVideoMode()
(I already call SDL_SetVideoMode() at the begining,
but I want to change video mode)
it works in windowed mode, but crash in fullscreen.

where is the problem ?

thank.

DUHAMEL Patrice <patrice.duhamel at m6net.fr> schrieb am 14 Feb 2001:

My program crash on Windows98 + SDL 1.2 + OpenGL FullScreen
when changing screen size with SDL_SetVideoMode()
(I already call SDL_SetVideoMode() at the begining,
but I want to change video mode)
it works in windowed mode, but crash in fullscreen.

where is the problem ?

Do not call SDL_QuitSubsystem before you call SDL_SetVideoMode()
again. There are some problems with SDL failing to correctly unload
the GL driver, so this is the recommended workaround.

See the following test-app:

------- cutHere ----------
#include <SDL.h>
#include <GL/gl.h>
#include <unistd.h>

SDL_Surface *screen;

void destroyWindow() {
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

int initWindow(width, height) {
if(SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0) {
fprintf(stderr, “can’t initialize Video: %s\n”, SDL_GetError());
exit(2);
}
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);

if( (screen = SDL_SetVideoMode( width, height, 0, SDL_OPENGL | SDL_FULLSCREEN)) == NULL ) {
fprintf(stderr, “Couldn’t set GL mode: %s\n”, SDL_GetError());
exit(1);
}
return 0;
}

void glCalls() {
glClearColor(0, 0, 0.3, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
fprintf(stderr, “%s %s %s”, glGetString(GL_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR));
SDL_GL_SwapBuffers();
}

int main( int argc, char *argv[] ) {
int i;

SDL_Init(SDL_INIT_NOPARACHUTE);
initWindow(640,480);
glCalls();
for(i = 0; i < 5; i++) {
fprintf(stderr, “%d…”, i);
SDL_Delay(1000);
}

/* don’t close the window! /
/
destroyWindow(); */

initWindow(800, 600);
glCalls();
SDL_Delay(3000);
destroyWindow();
return 0;
}
------- cutHere ----------

  • Andreas–
    Check out my 3D lightcycle game: http://www.gltron.org
    A 0.60 preview/beta for win32/mac is available NOW!
    More than 100’000 Downloads of the last version (0.59)