Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Cavalier Projection

This topic is 3671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I help my professor do the marking of a quiz, I came across a question about implementing Cavalier Projection using OpenGL. While the suggested answer from my professor and those I found on internet are both not very useful, I wrote one myself. Just in case someone might want to find one, here is the Cavalier Projection function I wrote.
void glOblique( GLdouble alpha, GLdouble phi, GLdouble aspect, GLdouble zNear, GLdouble zFar )
  double x, z, a, b, c, m[16];
  x = 1/aspect;
  a = cos(phi*PI/180)/tan(alpha*PI/180);
  b = sin(phi*PI/180)/tan(alpha*PI/180);
  z = -2/(zFar-zNear);
  c = -(zFar+zNear)/(zFar-zNear);
  m[0]=x; m[4]=0; m[ 8]=-a; m[12]=a;
  m[1]=0; m[5]=1; m[ 9]=-b; m[13]=b;
  m[2]=0; m[6]=0; m[10]= z; m[14]=c;
  m[3]=0; m[7]=0; m[11]= 0; m[15]=1;

Alpha and phi are measured in degree and they are defined as http://local.wasp.uwa.edu.au/~pbourke/geometry/classification/.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!