[SDL] Changing the Screen Size at Runtime

Michael Wyrzykowski wyrzy at juno.com
Tue Jan 11 11:11:43 PST 2005


> The SDL_VIDEORESIZE event doesn't do anything by itself. SDL does not
> take any action when it sees that event or when it generates that event.
> The event is there to tell you that the window has changed size. Your
> code is responsible for actually changing the displayable size of the
> window. What does your code do to handle the event? It should be calling
> SDL_SetVideoMode() to make the SDL surface match the new window size,
> and then (on Windows) reloading all your textures and probably
> recreating your OpenGL context. 
>
> If your code is not handling the SDL_VIDEORESIZE event then your        > program is not doing the right things when the window changes size. 
>
> 		Bob Pendleton
I am handling the SDL_VIDEORESIZE event like:
------
if(event.type == SDL_VIDEORESIZE)
{
    int width = event.resize.w;
    int height = event.resize.h;
    float scale_width = float(width)/800; //game logic set for
    float scale_height = float(height)/600;// 800x600 resolution

    glViewport( 0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho( 0, width, height, 0, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glScalef( scale_width, scale_height, 1.0f );
}
------
The above code works correctly when the mouse resizes the window without the need to call SDL_SetVideoMode() again. The result is basically the 800x600 screen is being projected over a larger or smaller area of pixels.

However, now that I am thinking of it, resizing the window is probably a windows-specfic item - or am I wrong? Does anyone know of a way to simulate the mouse resizing the window with SDL? I would assume that this is a windows specific item that SDL passes to the OS.

___________________________________________________________________
Speed up your surfing with Juno SpeedBand.
Now includes pop-up blocker!
Only $14.95/month -visit http://www.juno.com/surf to sign up today!





More information about the SDL mailing list