Skip to content

Instantly share code, notes, and snippets.

@netshade
Forked from anonymous/gist:604786
Created September 30, 2010 15:49
Show Gist options
  • Save netshade/604793 to your computer and use it in GitHub Desktop.
Save netshade/604793 to your computer and use it in GitHub Desktop.
-(void)setupView:(GLView*)view
{
const GLfloat zNear = -0.01, zFar = 1000.0, fieldOfView = 45.0;
GLfloat size;
glMatrixMode(GL_PROJECTION);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0);
CGRect rect = view.bounds;
glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size /
(rect.size.width / rect.size.height), zNear, zFar);
glViewport(0, 0, rect.size.width, rect.size.height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment