Преглед на файлове

3DFileViewer: Set correct aspect ratio in view frustum

Jelle Raaijmakers преди 3 години
родител
ревизия
61e4c09514
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      Userland/Applications/3DFileViewer/main.cpp

+ 3 - 1
Userland/Applications/3DFileViewer/main.cpp

@@ -71,7 +71,9 @@ private:
         // Set projection matrix
         // Set projection matrix
         glMatrixMode(GL_PROJECTION);
         glMatrixMode(GL_PROJECTION);
         glLoadIdentity();
         glLoadIdentity();
-        glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 1500);
+
+        auto const half_aspect_ratio = static_cast<double>(RENDER_WIDTH) / RENDER_HEIGHT / 2;
+        glFrustum(-half_aspect_ratio, half_aspect_ratio, -0.5, 0.5, 1, 1500);
 
 
         m_init_list = glGenLists(1);
         m_init_list = glGenLists(1);
         glNewList(m_init_list, GL_COMPILE);
         glNewList(m_init_list, GL_COMPILE);