SDL Mouse coordinates and RenderSetLogicalSize?


#1

The docs say that mouse coordinates should be relative to window (see here: https://wiki.libsdl.org/SDL_MouseMotionEvent).

Does this mean the max. mouse x position should be re-scaled to window width, and the max mouse y position should be re-scaled to window height? And min x and min y should both be zero?

But what about RenderSetLogicalSize? Why doesn’t that cause a re-scaling of mouse coordinates?

Also why does calling SDL_RenderGetLogicalSize() after creating a renderer return 0 and not the window width and height? Clearly the logical size is not zero in that case.

What exactly is affected by RenderSetLogicalSize? Only blitting functions that use rects? Why not mouse and touch coordinates etc.

What is supposed to happen when a Window is created with SDL_WINDOW_FULLSCREEN_DESKTOP, and then the desktop resolution is changed? Does the Window automatically resize? What about mouse coordinates in this case?

The docs are way too terse about all these things. None of my questions are answered by them.


#2

When using RenderSetLogicalSize, mouse events for that window will be scaled by SDL, as if the window itself were the logical size. The application shouldn’t scale these coordinates itself.

It does cause a rescaling.

It returns zero because there’s no logical size set (but one could argue this is a bug, too).

I wouldn’t be surprised if there are platforms that don’t handle this well, as it’s an uncommon thing to happen, but the window should resize (and logical sizes should remain the same, with SDL scaling as appropriate).