1.2 - screen resize

With SDL 1.2 does the SDL_Surface associated with the screen become
invalidated as soon as a resize event occurs? That is I have

screen = SDL_SetVideoMode(width, height, SCREEN_DEPTH, SDL_SWSURFACE |
SDL_RESIZABLE);

which I blit to and the event loop checks if a resize event occured and
if so will reset screen by calling SDL_SetVideoMode again. Is it ok to
draw to the screen before the event loop has processed the resize event?

I’m trying to track down a crash and this seems like the only plausible
culprit so far. I am running on Linux (X11).

Hello!

I think the general loop is something like:
process events
update objects (AI, collisions, etc)
clear screen (if you are doing a full frame draw)
draw.

Ideally, you would have caught the resize event and processed it before you started drawing. I’m almost certain that when you call SetVideoMode it will provide you with a new pointer to the screen, so if you call that command and then attempt to draw to the old pointer the result will most likely be a segfault. Other than that, if you are ensuring you are drawing to the right pointer, I’d assume the only problem would be that you’d lose the graphics drawn prior to the resize.

I hope this helps! Happy bug hunting :wink:

jon wrote:> With SDL 1.2 does the SDL_Surface associated with the screen become

invalidated as soon as a resize event occurs? That is I have

screen = SDL_SetVideoMode(width, height, SCREEN_DEPTH, SDL_SWSURFACE |
SDL_RESIZABLE);

which I blit to and the event loop checks if a resize event occured and
if so will reset screen by calling SDL_SetVideoMode again. Is it ok to
draw to the screen before the event loop has processed the resize event?

I’m trying to track down a crash and this seems like the only plausible
culprit so far. I am running on Linux (X11).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org