Specifies the coordinate for the left vertical clipping plane.
Specifies the coordinate for the right vertical clipping plane.
Specifies the coordinate for the bottom horizontal clipping plane.
Specifies the coordinate for the top horizontal clipping plane.
Specifies the distance to the near depth clipping plane. Must be positive.
Specifies the distance to the far depth clipping plane. Must be positive.
multiply the current matrix by a perspective matrix
Songho - OpenGL Matrix Class (C++)
Generated using TypeDoc
glFrustum
describes a perspective matrix that produces a perspective projection. The current matrix (see glMatrixMode) is multiplied by this matrix and the result replaces the current matrix, as if glMultMatrix were called with the following matrix as its argument:⎡ㅤ2 nearVal / right − leftㅤㅤㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ𝐀ㅤㅤㅤㅤ0ㅤ⎤
⎢ㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ2 nearVal / right − leftㅤㅤㅤ𝐁ㅤㅤㅤㅤ0ㅤ⎥
⎢ㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ𝐂ㅤㅤㅤㅤ𝐃ㅤ⎥
⎣ㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ0ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ−1ㅤㅤㅤㅤ0ㅤ⎦
𝐀 = right + left / right - left
𝐁 = top + bottom / top - bottom
𝐂 = −(farVal + nearVal) / farVal - nearVal
𝐃 = −2 farVal × nearVal / farVal - nearVal
Typically, the matrix mode is GL_PROJECTION, and (left, bottom, −nearVal) and (right, top, −nearVal) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, assuming that the eye is located at (0, 0, 0). −farVal specifies the location of the far clipping plane. Both nearVal and farVal must be positive.
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.