Browse Source

Merge remote-tracking branch 'iainmerrick/highdpi_fix'

Lasse Öörni 8 years ago
parent
commit
28e1f20487
1 changed files with 9 additions and 1 deletions
  1. 9 1
      Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

+ 9 - 1
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -505,7 +505,6 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     fullscreen_ = fullscreen;
     borderless_ = borderless;
     resizable_ = resizable;
-    highDPI_ = highDPI;
     vsync_ = vsync;
     tripleBuffer_ = tripleBuffer;
     multiSample_ = multiSample;
@@ -516,6 +515,10 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     if (!fullscreen)
         SDL_GetWindowPosition(window_, &position_.x_, &position_.y_);
 
+    int logicalWidth, logicalHeight;
+    SDL_GetWindowSize(window_, &logicalWidth, &logicalHeight);
+    highDPI_ = (width_ != logicalWidth) || (height_ != logicalHeight);
+
     // Reset rendertargets and viewport for the new screen mode
     ResetRenderTargets();
 
@@ -2262,6 +2265,10 @@ void Graphics::OnWindowResized()
     width_ = newWidth;
     height_ = newHeight;
 
+    int logicalWidth, logicalHeight;
+    SDL_GetWindowSize(window_, &logicalWidth, &logicalHeight);
+    highDPI_ = (width_ != logicalWidth) || (height_ != logicalHeight);
+
     // Reset rendertargets and viewport for the new screen size. Also clean up any FBO's, as they may be screen size dependent
     CleanupFramebuffers();
     ResetRenderTargets();
@@ -2276,6 +2283,7 @@ void Graphics::OnWindowResized()
     eventData[P_FULLSCREEN] = fullscreen_;
     eventData[P_RESIZABLE] = resizable_;
     eventData[P_BORDERLESS] = borderless_;
+    eventData[P_HIGHDPI] = highDPI_;
     SendEvent(E_SCREENMODE, eventData);
 }