VR mode
[laserbrain_demo] / src / main.cc
index 45b5632..01c9d12 100644 (file)
@@ -5,7 +5,7 @@
 #include <SDL2/SDL.h>
 #include "app.h"
 
-static bool init();
+static bool init(int argc, char **argv);
 static void process_event(SDL_Event *ev);
 static void proc_modkeys();
 
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
        SDL_GL_GetDrawableSize(win, &win_width, &win_height);
        win_aspect = (float)win_width / (float)win_height;
 
-       if(!init()) {
+       if(!init(argc, argv)) {
                SDL_Quit();
                return 1;
        }
@@ -90,11 +90,51 @@ unsigned int app_get_modifiers()
        return modkeys;
 }
 
-static bool init()
+void app_resize(int x, int y)
+{
+       SDL_SetWindowSize(win, x, y);
+}
+
+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;
+}
+
+
+static bool init(int argc, char **argv)
 {
        glewInit();
 
-       if(!app_init()) {
+       if(!app_init(argc, argv)) {
                return false;
        }