Created
November 16, 2011 22:41
-
-
Save heisters/1371724 to your computer and use it in GitHub Desktop.
reproduce gluPerspective in openFrameworks w/ ofxFenster and glFrustum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// useful as a basis for rendering parts of the image across multiple monitors | |
// see also http://www.opengl.org/wiki/GluPerspective_code | |
// and https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/gl/ofGLRenderer.cpp#L315 | |
void testApp::draw(){ | |
ofxFenster * win = ofxFensterManager::get()->getActiveWindow(); | |
ofPoint size = win->getWindowSize(); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
float halfFovTan = tanf(60 * PI / 360.0); | |
float baseDist = (size.y / 2) / halfFovTan; | |
float near = baseDist / 10.f; | |
float far = baseDist * 10.f; | |
float ymax = near * halfFovTan; | |
float xmax = (size.x / size.y) * ymax; | |
glFrustum(-xmax, xmax, -ymax, ymax, near, far); | |
glMatrixMode(GL_MODELVIEW); | |
// the rest of your draw here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👏 thanks for this gist