Browse Source

Retry window creation without multisampling.

Lasse Öörni 13 years ago
parent
commit
a2c547e5e3
1 changed files with 27 additions and 11 deletions
  1. 27 11
      Engine/Graphics/OpenGL/OGLGraphics.cpp

+ 27 - 11
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -293,18 +293,34 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool vsync, bool
             if (fullscreen)
             if (fullscreen)
                 flags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
                 flags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
             
             
-            if (!externalWindow_)
-                impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), x, y, width, height, flags);
-            else
-            {
-                if (!impl_->window_)
-                    impl_->window_ = SDL_CreateWindowFrom(externalWindow_);
-                fullscreen = false;
-            }
-            if (!impl_->window_)
+            for (;;)
             {
             {
-                LOGERROR("Could not open window");
-                return false;
+                if (!externalWindow_)
+                    impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), x, y, width, height, flags);
+                else
+                {
+                    if (!impl_->window_)
+                        impl_->window_ = SDL_CreateWindowFrom(externalWindow_);
+                    fullscreen = false;
+                }
+                
+                if (impl_->window_)
+                    break;
+                else
+                {
+                    if (multiSample > 1)
+                    {
+                        // If failed with multisampling, retry first without
+                        multiSample = 1;
+                        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
+                        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
+                    }
+                    else
+                    {
+                        LOGERROR("Could not open window");
+                        return false;
+                    }
+                }
             }
             }
             
             
             // Create/restore context and GPU objects and set initial renderstate
             // Create/restore context and GPU objects and set initial renderstate