]> git.jsancho.org Git - lugaru.git/blobdiff - Source/OpenGL_Windows.cpp
Drop keyboard input if it was part of the grab or window/fullscreen toggle.
[lugaru.git] / Source / OpenGL_Windows.cpp
index 226025a7a7a9dba7a193da91fc4cf2ad112cc088..a37cdda07b671cc376182fc44b44374f951f3e86 100644 (file)
@@ -470,6 +470,7 @@ static inline int clamp_sdl_mouse_button(Uint8 button)
 static void sdlEventProc(const SDL_Event &e, Game &game)
 {
     int val;
+    bool skipkey = false;
     SDLMod mod;
 
     switch(e.type)
@@ -508,6 +509,7 @@ static void sdlEventProc(const SDL_Event &e, Game &game)
             {
                 if (e.key.keysym.mod & KMOD_CTRL)
                 {
+                    skipkey = true;
                     SDL_GrabMode mode = SDL_GRAB_ON;
                     if ((SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) == 0)
                     {
@@ -518,23 +520,16 @@ static void sdlEventProc(const SDL_Event &e, Game &game)
                 }
             }
 
-            #if (defined(__APPLE__) && defined(__MACH__))
-            if (e.key.keysym.sym == SDLK_q)
-            {
-                if (e.key.keysym.mod & KMOD_META)
-                {
-                    gDone=true;
-                }
-            }
-            #endif
-
             else if (e.key.keysym.sym == SDLK_RETURN)
             {
                 if (e.key.keysym.mod & KMOD_ALT)
+                {
+                    skipkey = true;
                     SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+                }
             }
 
-            if (e.key.keysym.sym < SDLK_LAST)
+            if ((!skipkey) && (e.key.keysym.sym < SDLK_LAST))
             {
                 if (KeyTable[e.key.keysym.sym] != 0xffff)
                     SetKey(KeyTable[e.key.keysym.sym]);
@@ -545,6 +540,8 @@ static void sdlEventProc(const SDL_Event &e, Game &game)
                 SetKey(MAC_CONTROL_KEY);
             if (mod & KMOD_ALT)
                 SetKey(MAC_OPTION_KEY);
+            if (mod & KMOD_META)
+                SetKey(MAC_COMMAND_KEY);
             if (mod & KMOD_SHIFT)
                 SetKey(MAC_SHIFT_KEY);
             if (mod & KMOD_CAPS)
@@ -936,6 +933,8 @@ Boolean SetUp (Game & game)
 
     SDL_ShowCursor(0);
 
+    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
     if (SDL_SetVideoMode(kContextWidth, kContextHeight, 0, sdlflags) == NULL)
     {
         fprintf(stderr, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
@@ -955,6 +954,14 @@ Boolean SetUp (Game & game)
         }
     }
 
+    int dblbuf = 0;
+    if ((SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dblbuf) == -1) || (!dblbuf))
+    {
+        fprintf(stderr, "Failed to get double buffered GL context!\n");
+        SDL_Quit();
+        return false;
+    }
+
     if (!lookup_all_glsyms())
     {
         SDL_Quit();