I've been trying to build a 3D camera system in SDL2 with OpenGL so that I can use the mouse to look around. With glfw it's possible to trap the mouse in the window, and keep it centered with a library call, so I was looking for something equivalent in SDL2.
In order to process mouse events in the main loop I'm checking for
Searching around the web, I've found that SDL2 allows for mouse trapping with the call to
SDL_SetRelativeMouseMode(). With this call, though, the mouse is trapped and limited to move within the window, and not just at the center. This causes the mouse to be able to move from the top left corner at
(0,0) to the bottom right corner at
(WIDTH,HEIGHT), and not any further.
I've tried to fix this by repositioning the cursor position with
SDL_WarpMouseInWindow(), but this generates a
SDL_MOUSEMOTION event as well, basically resetting any movement I might've tried to do.
How can I fix this?