SteinSOFT.net
  gluPerspective Replacement

This should be familiar to you: because you would like to create a hot, little OpenGL demo using a perspective projection you have to use gluPerspective(..) - unless you're one of those rare people that understand the magic behind glFrustrum(..) - and logically link GLU against your application but unfortunately you load the library only to use this little, damn function. Help if here now!

The solution: code your own gluPerspective(..) implementation. Fortunately all this isn't that difficult and if you don't understand the code, be sure, it works! Btw. the code has been partly borrowed from the GLU implementation of Mesa GL. Thanks to them!

//additional includes
#include <math.h>

void
gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
   GLdouble xmin, xmax, ymin, ymax;

   ymax = zNear * tan(fovy * M_PI / 360.0);
   ymin = -ymax;
   xmin = ymin * aspect;
   xmax = ymax * aspect;


   glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}

I assume you have basic knowledge of how to use this function - otherwise you wouldn't have read this snippet, right? From now on you'll never have to link GLU only for this function. Happy c0ding!

Copyright © by SteinSOFT