Преглед изворни кода

~ fix resolutions higher than your current window

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez пре 5 година
родитељ
комит
73c40c3d4e
1 измењених фајлова са 20 додато и 1 уклоњено
  1. 20 1
      src/WallpaperEngine/Render/CWallpaper.cpp

+ 20 - 1
src/WallpaperEngine/Render/CWallpaper.cpp

@@ -203,6 +203,22 @@ void CWallpaper::render (glm::vec4 viewport, bool newFrame)
     float widthRatio = windowWidth / viewport.z;
     float heightRatio = windowHeight / viewport.w;
 
+    if (widthRatio > 1.0f)
+    {
+        float diff = widthRatio - 1.0f;
+
+        widthRatio -= diff;
+        heightRatio -= diff;
+    }
+
+    if (heightRatio > 1.0f)
+    {
+        float diff = heightRatio - 1.0f;
+
+        widthRatio -= diff;
+        heightRatio -= diff;
+    }
+
     if (widthRatio < 1.0f)
     {
         float diff = 1.0f - widthRatio;
@@ -213,12 +229,15 @@ void CWallpaper::render (glm::vec4 viewport, bool newFrame)
 
     if (heightRatio < 1.0f)
     {
-        float diff = 1.0f - widthRatio;
+        float diff = 1.0f - heightRatio;
 
         widthRatio += diff;
         heightRatio += diff;
     }
 
+    if (widthRatio < 0.0f) widthRatio = -widthRatio;
+    if (heightRatio < 0.0f) heightRatio = -heightRatio;
+
     GLfloat position [] = {
         widthRatio * -1.0f, heightRatio * 1.0f, 0.0f,
         widthRatio * 1.0f, heightRatio * 1.0f, 0.0f,