gluPerspective Question

Is there a way to update gluPerspective by using LoadIdentity or anything else?

Thank You.

  • VC6-OGL

The implementation of gluperspective is not complex; you can substitute your own. I use something like this:

// Set up projection matrix.
// This is slightly non-standard, since I prefer right-handed
// view coordinates, while OpenGL defaults to a left-handed system.
//
float nearz = NEAR_CUTOFF;
float farz = FAR_CUTOFF;
float fovy = FOV_Y;
float AspectRatio = float(h) / float(w);
float ViewAngleH = fovy * (PI / 180);
float ViewAngleV = atan(tan(ViewAngleH/2) * AspectRatio) * 2;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float m[16];
int i;
for (i = 0; i < 16; i++) m[i] = 0;
m[0] = -1.0 / tan(ViewAngleH / 2);
m[5] = -m[0] / AspectRatio;
m[10] = (farz + nearz) / (farz - nearz);
m[11] = 1;
m[14] = - 2 * farz * nearz / (farz - nearz);
glMultMatrixf(m);
glMatrixMode(GL_MODELVIEW);