Checking for Window move/resize with SDL?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Checking for Window move/resize with SDL?

Post 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).
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Checking for Window move/resize with SDL?

Post 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
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Checking for Window move/resize with SDL?

Post 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.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Checking for Window move/resize with SDL?

Post 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. ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Checking for Window move/resize with SDL?

Post by eatcomics »

I'm sure it has something to do with an SDL_Event...
Image
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: Checking for Window move/resize with SDL?

Post 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.
Post Reply