[SDL] How to get resolution of my SDL window?

voidstar voidstar at tin.it
Wed Dec 5 04:34:16 PST 2007


> width=screen->w;
> 
> height=screen->h;

Yes, but in this way I can't get the correct window resolution if I've
resized the window while the SDL_VIDEORESIZE was disabled.

In this case, if I resize the window, for SDL the window is not resized,
so screen->w e screen->h are unchanged... but the window is resized (not
SDL updated, but resized).

I need this check because i want to restore window resolution if the user
try to resize the window while the SDL_VIDEORESIZE event is disabled.

However, I've found this way to do it:

  RECT windowRect;
  GetClientRect(hWnd, &windowRect);
  int real_w = windowRect.right-windowRect.left;
  int real_h = windowRect.bottom-windowRect.top;

I think this is the only way to do it... or not?
What do you think?

Thank you for your help!




More information about the SDL mailing list