static SDL_Window *win;
static SDL_GLContext ctx;
static bool redraw_pending = true;
+static bool fullscreen, mouse_grabbed;
static bool quit;
static int scale_factor = 1;
void app_fullscreen(bool fs)
{
SDL_SetWindowFullscreen(win, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
+ fullscreen = fs;
+}
+
+void app_toggle_fullscreen()
+{
+ app_fullscreen(!fullscreen);
+}
+
+bool app_is_fullscreen()
+{
+ return fullscreen;
+}
+
+void app_grab_mouse(bool grab)
+{
+ /*SDL_SetWindowGrab(win, grab ? SDL_TRUE : SDL_FALSE);
+ SDL_ShowCursor(grab ? 1 : 0);
+ */
+ SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE);
+ mouse_grabbed = grab;
+}
+
+void app_toggle_grab_mouse()
+{
+ app_grab_mouse(!mouse_grabbed);
+}
+
+bool app_is_mouse_grabbed()
+{
+ return mouse_grabbed;
}
void app_quit()
break;
case SDL_MOUSEMOTION:
- app_mouse_motion(ev->motion.x * scale_factor, ev->motion.y * scale_factor);
+ if(mouse_grabbed) {
+ app_mouse_delta(ev->motion.xrel, ev->motion.yrel);
+ } else {
+ app_mouse_motion(ev->motion.x * scale_factor, ev->motion.y * scale_factor);
+ }
break;
case SDL_WINDOWEVENT: