gluPerspective

One of the convenience methods removed from OpenGL ES is gluPerspective. At some point, I ran across the code for this method (this isn't my code, but I'm not sure who I got it from. If this came from you, let me know and I will credit you). Anyone who's feeling sad because gluPerspective is not available on the iPhone, rejoice, for here it is:
- (void)gluPerspective:(double)fovy :(double)aspect :(double)zNear :(double)zFar
{
// Start in projection mode.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustumf(xmin, xmax, ymin, ymax, zNear, zFar);
}

Seems silly to not have this, given how short it is.

0 komentar:

Post a Comment

  • Digg
  • del.icio.us
  • StumbleUpon
  • Yahoo! Buzz
  • Technorati
  • Facebook
  • TwitThis
  • MySpace
  • LinkedIn
  • Google
  • Reddit
  • Netvibes
Design by Blogger Tune-UpCopyright © 2011 Gadget Reviews Update 2012 | Powered by Blogger