Windows resize (openGL)

I need to determine when SDL is finished resizing, and “while
(!SDL_GetVideoSurface())”, doesn’t work for that. So how can I determine
when an SDL window has finished resizing, so I can start using openGL calls?

Note that the code below works on initation, and from windows->fullscreen,
but not from fullscreen-> window. There are also no SDL errors reported, it
just succeeds. When It starts calling openGL functions there is no opengl
context to draw too, causing errors.

When resizing to a smaller window, in windows, I use this code:

void initSDL(int w, int h, int colour)


    // Initialize the SDL library

    if( SDL_Init(SDL_INIT_VIDEO) < 0 )


        //An error occured so report it. They can check the error log

for this message.

        cerr << "[Error] Couldn't initialize SDL VIDEO: " <<

SDL_GetError() << “\n”;

        //Display a message to the user

        AfxMessageBox("Couldn't initialize SDL VIDEO! See the error


        exit(1); //Quick Exit with error number 1


    // Forces a clean up on exit


    //Initialize the display in a wxh colour-bit, requesting hardware

(faster) surfaces.

    if (SDL_SetVideoMode(w, h, colour, VideoFlag))


        //Setup windows caption


        //Set up the amount SDL gives each colour (32-bit)

        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );

        SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );

        SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );

        SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );

        //Enabled z-buffer even though not used (disable to save memory

and speed)

        SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, ZDEPTH );

        SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

        //Disable keyboard repeating, so that the program only receives

the keyboard down

        //message once.

        SDL_EnableKeyRepeat(0, 0);

        //Wait for SDL to be ready (probably should have a timeout)

        while (!SDL_GetVideoSurface());




        //Nope, there was an error setting that video mode

        cerr << "[Error] Couldn't set video mode: " << SDL_GetError() <<


        AfxMessageBox("Couldn't set video mode! See the error log.");





//Resize the window
VideoFlag &= !SDL_FULLSCREEN; //Remove fullscreen (it was fullscreen before)

//Reset things

SDL_Quit(); //Parhaps should be SDL_QuitSubSystem(SDL_INIT_VIDEO);

initAll(ScreenWidth, ScreenHeight, ColourDepth);