I have a scene that I'm rendering first with a perspective matrix. I then want to rerender it in a different viewport using an orthographic matrix for a top-down 2D view of the scene. I think I may be missing something because I get nothing rendered with the orthographic projection.

To setup the ortho projection I create the matrix with the near/far set to (-1,1) (not sure how it affects rendering) and then move the camera up and pitch it 90 degrees and rerender the vertices without modification.

I'm using OpenGL4 with glm to produce the matrices.

  • \$\begingroup\$ The near and far planes control the range of depths around the camera that will be rendered. With [-1, 1] as the range you will only render objects that are within 1 unit of the camera in depth. Are you sure your scene lies within that range? \$\endgroup\$ – Nathan Reed Aug 20 '13 at 18:48

When rendering with an ortographic projection, you need to set your model view matrix to identity.

To learn more about projection matrices, I'd suggest reading this article: http://www.songho.ca/opengl/gl_projectionmatrix.html

| improve this answer | |
  • 4
    \$\begingroup\$ No, you don't "need to" set your modelview matrix to identity. You can use it to rotate and translate the view in an orthographic projection just as you do in a perspective projection. \$\endgroup\$ – Nathan Reed Aug 20 '13 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.