No need to use windows-specific functions…
Just use the SDL_GetVideoSurface() function. It returns a pointer to the
current display surface. you can even use it directly:
int screen_width = SDL_GetVideoSurface()->w; // this gives surface width
int screen_height = SDL_GetVideoSurface()->h; // this gives surface height
if you assign it to an existing pointer (screen = SDL_GetVideoSurface() it
will only work until the screen is resized, at which point you must reassign
the pointer to the changed video surface. (similar, if not identical, to
what you have been describing.)
I’ve tried to use GetVideoSurface() function, but it doesn’t “notice” that my
window has been resized while SDL_VIDEORESIZE events are disabled.
The situation is the following:
When the user keep space-bar pressed, I show a picture and I disable
SDL_VIDEORESIZE events (and mouse events too)
If the user (while pressing space-bar) try to resize the window with the mouse,
SDL doen’t receive the resize event, so it doesn’t update the screen, but
Windows resize the window (the window is larger/smaller)!
So, when the user release space-bar, I want the window to return to the original
resolution (because this is an invalid resize for my app), but I want to do this
only if the user resized the window while pressing space-bar.
To check is the user resized the window while pressing space-bar, I have to
check the new real window resolution, and compare it with his resolution
before pressing space-bar.
The problem with SDL_GetVideoSurface is that when the user release space-bar,
SDL_GetVideoSurface()->w and SDL_GetVideoSurface()->h return me the original
resolution, also if the user resized the window while SDL_VIDEORESIZE events
Instead, using GetClientRect I can obtain the new real window resolution.
Do you know if there’s another way to do this using SDL?
Thanks for you help