[SDL] Changing the Screen Size at Runtime

Michael Wyrzykowski wyrzy at juno.com
Mon Jan 10 20:54:11 PST 2005


I am using SDL w/ OpenGL for rendering, and I was wondering if there is any way to change the resolution by code without needing to re-load in all currently loaded textures?

I have tried pushing my own event onto the event queue like:
SDL_Event custom_event;
custom_event.resize.h = new_height; //<--the height to set the window at
custom_event.resize.w = new_width; //<--the width to set the window at
custom_event.type = SDL_VIDEORESIZE;
custom_event.resize.type = SDL_VIDEORESIZE;
  printf("SDL_PushEvent Error: %s", SDL_GetError);
but I receive no error message so I assume the event was pushed properly.

When I resize the window with the mouse pointer by dragging the edges of the window, the screen is resized properly when I look for an SDL_VIDEORESIZE event. However, when I go to retreive the SDL_VIDEORESIZE after running the above code, the window does not change dimensions. I want people who will play the game to be able to pick standard resolutions (1024x768, 800x600, 640x480,...), so I don't really want to rely on them resizing the screen with the mouse pointer.

I realize that I can call SDL_SetVideoMode again, but then I also need to re-load in all my textures or I end up with a black screen. This is what I'm doing now, but it takes a few seconds to load in all the currently loaded images, set the color keys... which I would like avoid if possible.

Does anyone know if I am allowed to trigger a SDL_VIDEORESIZE event by pushing it onto the event queue? Thank you for any help and/or suggestions you can give :)

Btw, I'm running on a Windows box.

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