Search code examples
openglrotationprojection

Can I rotate the view of glOrtho()?


I'm making a program where I need an orthographic projection. So, I'm using glOrtho(). I made a zoom function but I was wandering if you can rotate your view? Because glOrho() only looks parralel to other planes. Or is there another projection wich can do that. glLookAt can rotate but it changes dimensions when further from the camera. I read
How can I make the glOrtho parallelepiped rotating? but it didn't give me an answer.


Solution

  • What's essential here is that you usually split the operations into two matrices: The (Model)View and The Projection.

    While glOrtho() is usually called with glMatrixMode(GL_PROJECTION), all operations regarding moving and rotating the camera (such as glRotate*, glTranslate* and gluLookAt) should be preceeded by glMatrixMode(GL_MODELVIEW).

    In fixed pipeline, the final position of the vertex is calculated by multiplying input data by these two matrices, and the projection used (orthographic or perspective or nonlinear whatnot) is separate from camera transformations.