I’m on Linux Mint and SDL_GetWindowSize() returns the wrong values. This same thing happened when I tried using another library (SFML) so I guess this problem has to do with the Desktop Environment of Linux Mint.
In order to resize the window correctly I have to call the function every frame in order to prevent giving a wrong value. How expensive is this processing wise? Will this affect the performance of my game?
Not sure this will help you, but I remember this was slow, indeed. The trick consisted in catch the window event happening when resizing, and use event.window.data1 (giving width), and event.window.data2 (giving height).
Not sure this is a clean solution, be below what I’m using, and it is really faster:
e.g. (see: Sources/src/Application/engine.cpp · master · Eric Bachard / miniDart · GitLab and Sources/inc/engine.hpp · master · Eric Bachard / miniDart · GitLab for the details ):
switch (event.type)
{
case SDL_WINDOWEVENT:
{
switch(event.window.event)
{
case SDL_WINDOWEVENT_RESIZED:
// faster than SDL_GetWindowSize(window, ¤tWidth, ¤tHeight);
engine.setWidth(event.window.data1);
engine.setHeight(event.window.data2);
break;
default:
break;
}
}
break;
case SDL_DROPFILE:
break;