]> git.jsancho.org Git - lugaru.git/blobdiff - Source/OpenGL_Windows.cpp
Added GPL license and headers.
[lugaru.git] / Source / OpenGL_Windows.cpp
index 244e13505d85949f081aa5db625b5c6f1e471194..b4faa6658a93c66891d652b7198503e657334681 100644 (file)
@@ -1,3 +1,24 @@
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+
 
 #ifdef WIN32
 #include <vld.h>
@@ -470,6 +491,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 +530,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)
                     {
@@ -521,10 +544,13 @@ static void sdlEventProc(const SDL_Event &e, Game &game)
             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]);
@@ -928,6 +954,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());
@@ -947,6 +975,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();