Browse Source

Replaced deprecated gluPerspective()

Thomas Buck 10 years ago
parent
commit
b96a0f70be
2 changed files with 16 additions and 2 deletions
  1. 8
    1
      src/SDLSystem.cpp
  2. 8
    1
      src/System.cpp

+ 8
- 1
src/SDLSystem.cpp View File

30
 #include <stdlib.h>
30
 #include <stdlib.h>
31
 #include <stdio.h>
31
 #include <stdio.h>
32
 #include <string.h>
32
 #include <string.h>
33
+#include <cmath>
33
 
34
 
34
 #ifdef MEMEORY_TEST
35
 #ifdef MEMEORY_TEST
35
 #   include "memeory_test.h"
36
 #   include "memeory_test.h"
289
 
290
 
290
 	glMatrixMode(GL_PROJECTION);
291
 	glMatrixMode(GL_PROJECTION);
291
 	glLoadIdentity();
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
 	glMatrixMode(GL_MODELVIEW);
301
 	glMatrixMode(GL_MODELVIEW);
295
 	glLoadIdentity();
302
 	glLoadIdentity();

+ 8
- 1
src/System.cpp View File

25
 #include <sys/types.h>
25
 #include <sys/types.h>
26
 #include <string.h>
26
 #include <string.h>
27
 #include <stdarg.h>
27
 #include <stdarg.h>
28
+#include <cmath>
28
 
29
 
29
 #ifdef USING_OPENGL
30
 #ifdef USING_OPENGL
30
 #ifdef __APPLE__
31
 #ifdef __APPLE__
650
 	glLoadIdentity();
651
 	glLoadIdentity();
651
 
652
 
652
 	// Adjust clipping
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
 	glMatrixMode(GL_MODELVIEW);
661
 	glMatrixMode(GL_MODELVIEW);
655
 }
662
 }
656
 
663
 

Loading…
Cancel
Save