瀏覽代碼

fixed ratio and resize

develop
Robin Thoni 8 年之前
父節點
當前提交
795803376b
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8
    4
      TheGame/openglrenderdevice.cpp

+ 8
- 4
TheGame/openglrenderdevice.cpp 查看文件

@@ -113,7 +113,7 @@ void OpenGLRenderDevice::initialize(int fov, int width, int height)
113 113
 //    glEnable(GL_CULL_FACE);
114 114
 
115 115
     glMatrixMode(GL_PROJECTION);
116
-    gluPerspective(_fov, _width / _height, 0.1, 100.0);
116
+    gluPerspective(_fov, (double)_width / _height, 0.1, 100.0);
117 117
     glMatrixMode(GL_MODELVIEW);
118 118
 }
119 119
 
@@ -121,9 +121,13 @@ void OpenGLRenderDevice::resize(int width, int height)
121 121
 {
122 122
     _width = width;
123 123
     _height = height;
124
-//    glViewport(0, 0, _width, _height);
125
-    int side = qMin(_width, _height);
126
-    glViewport((_width - side) / 2, (_height - side) / 2, side, side);
124
+    glViewport(0, 0, _width, _height);
125
+
126
+    glMatrixMode(GL_PROJECTION);
127
+    glLoadIdentity();
128
+    gluPerspective(_fov, (double)_width / _height, 0.1, 100.0);
129
+    glMatrixMode(GL_MODELVIEW);
130
+    glLoadIdentity();
127 131
 }
128 132
 
129 133
 void OpenGLRenderDevice::preDraw()

Loading…
取消
儲存