Well yes, I did forget to convert from degrees to radians but it didn’t help.
Here is a code snipset from my program:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
#define DEG2RAD(x) ((x) * 0.0174532925f)
#define M_PI_2 6.28318531f
float fieldOfView = 60.0f;
float aspectRatio = 800.0f / 600.0f;
float nearPlane = 1.0f;
float farPlane = 1000.0f;
float f = tanf( M_PI_2 - DEG2RAD( fieldOfView ) * 0.5f );
GLfloat mat[16];
mat[0] = f / aspectRatio;
mat[1] = 0.0f;
mat[2] = 0.0f;
mat[3] = 0.0f;
mat[4] = 0.0f;
mat[5] = f;
mat[6] = 0.0f;
mat[7] = 0.0f;
mat[8] = 0.0f;
mat[9] = 0.0f;
mat[10] = ( farPlane + nearPlane ) / ( nearPlane - farPlane );
mat[11] = -1.0f;
mat[12] = 0.0f;
mat[13] = 0.0f;
mat[14] = ( 2.0f * farPlane * nearPlane ) / ( nearPlane - farPlane );
mat[15] = 0.0f;
glMatrixMode( GL_PROJECTION );
glLoadMatrixf( mat );
//glLoadIdentity();
//gluPerspective( 60.0f, 800.0f / 600.0f, 1.0f, 1000.0f );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -10.0f );
glBegin( GL_LINES );
glColor3f( 0.0f, 1.0f, 1.0f );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 1.0f, 0.0f, 0.0f );
glColor3f( 1.0f, 0.0f, 1.0f );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 1.0f, 0.0f );
glColor3f( 1.0f, 1.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, 1.0f );
glEnd();
The matrix formula was taken from “OpenGL Reference Manual” 3rd edition.
Here is a screenshot if I use gluPerspective instead of my own matrix.
Here is a screenshot when I use my own matrix without DEG2RAD.
And here is a screenshot when I use DEG2RAD.
Any ideas?