Page 1 of 1

Checking for Window move/resize with SDL?

Posted: Wed Dec 09, 2009 4:07 pm
by Falco Girgis
I haven't really gone out and researched, but I was wondering if anybody knew (off the top of their head) if SDL provided a way to check if the window was being moved, resized, or anything else that would pause game logic (and thus fuck up any delta-time based calculations).

Re: Checking for Window move/resize with SDL?

Posted: Wed Dec 09, 2009 5:17 pm
by andrew
I looked earlier in "Focus on SDL," but I didn't find where it really talks about it.

Lazy Foo has this: Resizable Windows and Window Events

Re: Checking for Window move/resize with SDL?

Posted: Wed Dec 09, 2009 7:39 pm
by XianForce
VIDEORESIZE event for resizes and I think, not entirely sure, but I think that VIDEOEXPOSE event will take care of moving the window.

As far as I know, a VIDEOEXPOSE event is called when something modifies the screen outside of the game/app... so I think that it would work.

Here's the event structures if you need them:

Code: Select all

//VIDEOEXPOSE
typedef struct{
  Uint8 type
} SDL_ExposeEvent;

//VIDEORESIZE
typedef struct{
  Uint8 type;
  int w, h;
} SDL_ResizeEvent;
Hope that helps =D.

Re: Checking for Window move/resize with SDL?

Posted: Thu Dec 10, 2009 10:59 am
by dandymcgee
http://sdl.beuc.net/sdl.wiki/SDL_SetVideoMode wrote:Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL_SetVideoMode. In Linux, however, it works fine, and the initialization code only needs to be executed after the first call to SDL_SetVideoMode (although there is no harm in executing the initialization code after each call to SDL_SetVideoMode, for example for a multiplatform application).
If you try to resize the actual screen surface in SDL on Windows, you will have to reinitialize your entire OpenGL system. If your goal is to just detect it, then disregard this. ;)

Re: Checking for Window move/resize with SDL?

Posted: Sat Dec 12, 2009 9:12 pm
by eatcomics
I'm sure it has something to do with an SDL_Event...

Re: Checking for Window move/resize with SDL?

Posted: Sun Dec 13, 2009 2:02 pm
by TheBuzzSaw
If your event.type == SDL_VIDEORESIZE, the window has been resized.

I'm not sure if there is a way to see if the window is moving, but you might be able to form a workaround using SDL_APPINPUTFOCUS.