Last active
April 3, 2016 14:47
-
-
Save satoruhiga/4714050 to your computer and use it in GitHub Desktop.
getCurrentFov.cpp
This file contains 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
float getCurrentFov() | |
{ | |
GLfloat m[16]; | |
GLint viewport[4]; | |
glGetFloatv(GL_PROJECTION_MATRIX, m); | |
glGetIntegerv(GL_VIEWPORT, viewport); | |
float aspect = (float)viewport[2] / viewport[3]; | |
// m[0] / aspect = cot(fovy / 2) | |
float a = (m[0] * aspect); | |
float fov = (atan(a) - M_PI_2) * -2; | |
return ofRadToDeg(fov); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment