Sfoglia il codice sorgente

Replaced deprecated gluPerspective()

Thomas Buck 11 anni fa
parent
commit
b96a0f70be
2 ha cambiato i file con 16 aggiunte e 2 eliminazioni
  1. 8
    1
      src/SDLSystem.cpp
  2. 8
    1
      src/System.cpp

+ 8
- 1
src/SDLSystem.cpp Vedi File

@@ -30,6 +30,7 @@
30 30
 #include <stdlib.h>
31 31
 #include <stdio.h>
32 32
 #include <string.h>
33
+#include <cmath>
33 34
 
34 35
 #ifdef MEMEORY_TEST
35 36
 #   include "memeory_test.h"
@@ -289,7 +290,13 @@ void SDLSystem::resize(unsigned int width, unsigned int height)
289 290
 
290 291
 	glMatrixMode(GL_PROJECTION);
291 292
 	glLoadIdentity();
292
-	gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
293
+
294
+    // gluPerspective is deprecated!
295
+	// gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
296
+    // fix: http://stackoverflow.com/a/2417756
297
+    GLfloat fH = tan(float(m_fovY / 360.0f * 3.14159f) ) * m_clipNear;
298
+    GLfloat fW = fH * aspect;
299
+    glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
293 300
 
294 301
 	glMatrixMode(GL_MODELVIEW);
295 302
 	glLoadIdentity();

+ 8
- 1
src/System.cpp Vedi File

@@ -25,6 +25,7 @@
25 25
 #include <sys/types.h>
26 26
 #include <string.h>
27 27
 #include <stdarg.h>
28
+#include <cmath>
28 29
 
29 30
 #ifdef USING_OPENGL
30 31
 #ifdef __APPLE__
@@ -650,7 +651,13 @@ void System::resizeGL(unsigned int w, unsigned int h)
650 651
 	glLoadIdentity();
651 652
 
652 653
 	// Adjust clipping
653
-	gluPerspective(m_fovY, ((GLdouble)w)/((GLdouble)h), m_clipNear, m_clipFar);
654
+    // gluPerspective is deprecated!
655
+	// gluPerspective(m_fovY, ((GLdouble)w)/((GLdouble)h), m_clipNear, m_clipFar);
656
+    // Fix: http://stackoverflow.com/a/2417756
657
+    GLfloat fH = tan(float(m_fovY / 360.0f * 3.14159f)) * m_clipNear;
658
+    GLfloat fW = fH * ((GLdouble)w)/((GLdouble)h);
659
+    glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
660
+
654 661
 	glMatrixMode(GL_MODELVIEW);
655 662
 }
656 663
 

Loading…
Annulla
Salva