瀏覽代碼

Add centering for initial window creation for OGL

Josh Engebretson 10 年之前
父節點
當前提交
7b7be56b15
共有 2 個文件被更改,包括 9 次插入7 次删除
  1. 8 5
      Source/Atomic/Graphics/OpenGL/OGLGraphics.cpp
  2. 1 2
      Source/Atomic/Graphics/OpenGL/OGLGraphics.h

+ 8 - 5
Source/Atomic/Graphics/OpenGL/OGLGraphics.cpp

@@ -334,7 +334,7 @@ void* Graphics::GetSDLWindow()
 }
 }
 
 
 bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer,
 bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer,
-    int multiSample, bool maximize)
+    int multiSample, bool maximize, bool center)
 {
 {
     PROFILE(SetScreenMode);
     PROFILE(SetScreenMode);
 
 
@@ -508,9 +508,12 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
 
 
         CreateWindowIcon();
         CreateWindowIcon();
 
 
-        if (maximize)
+        if (maximize || center)
         {
         {
-            Maximize();
+            if (maximize)
+                Maximize();
+            else if (center)
+                CenterWindow();
             SDL_GetWindowSize(impl_->window_, &width, &height);
             SDL_GetWindowSize(impl_->window_, &width, &height);
         }
         }
 
 
@@ -577,7 +580,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
 
 
 bool Graphics::SetMode(int width, int height)
 bool Graphics::SetMode(int width, int height)
 {
 {
-    return SetMode(width, height, fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_, false);
+    return SetMode(width, height, fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_, false, false);
 }
 }
 
 
 void Graphics::SetSRGB(bool enable)
 void Graphics::SetSRGB(bool enable)
@@ -614,7 +617,7 @@ void Graphics::SetOrientations(const String& orientations)
 
 
 bool Graphics::ToggleFullscreen()
 bool Graphics::ToggleFullscreen()
 {
 {
-    return SetMode(width_, height_, !fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_, false);
+    return SetMode(width_, height_, !fullscreen_, borderless_, resizable_, vsync_, tripleBuffer_, multiSample_, false, false);
 }
 }
 
 
 void Graphics::Close()
 void Graphics::Close()

+ 1 - 2
Source/Atomic/Graphics/OpenGL/OGLGraphics.h

@@ -103,8 +103,7 @@ public:
     /// Get the SDL_Window as a void* to avoid having to include the graphics implementation
     /// Get the SDL_Window as a void* to avoid having to include the graphics implementation
     void* GetSDLWindow();
     void* GetSDLWindow();
     /// Set screen mode. Return true if successful.
     /// Set screen mode. Return true if successful.
-    bool SetMode
-        (int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample, bool maximize);
+    bool SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample, bool maximize, bool center);
     /// Set screen resolution only. Return true if successful.
     /// Set screen resolution only. Return true if successful.
     bool SetMode(int width, int height);
     bool SetMode(int width, int height);
     /// Set whether the main window uses sRGB conversion on write.
     /// Set whether the main window uses sRGB conversion on write.