Browse Source

fixed ratio and resize

develop
Robin Thoni 8 years ago
parent
commit
795803376b
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      TheGame/openglrenderdevice.cpp

+ 8
- 4
TheGame/openglrenderdevice.cpp View File

@@ -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…
Cancel
Save