I am trying to have one of the viewports in my window display an orthographic projection of a teapot.
mat4 view = translate (identity_mat4 (), vec3 (0.0, 0.0, -40.0));
mat4 persp_proj = perspective(50.0, (float)width/(float)height, 0.1, 100.0);
mat4 model = rotate_x_deg (identity_mat4 (), 40);
glViewport (0, 0, width / 2, height / 2);
glOrtho(0,400,0,300,0,1);
glUniformMatrix4fv (proj_mat_location, 1, GL_FALSE, persp_proj.m);
glUniformMatrix4fv (view_mat_location, 1, GL_FALSE, view.m);
glUniformMatrix4fv (matrix_location, 1, GL_FALSE, model.m);
glDrawArrays (GL_TRIANGLES, 0, teapot_vertex_count);
This is the part in the code that I would like to use glOrtho
to draw an orthographic view of the teapot. First of all, am I even using glOrtho
correctly? I think I am, but I'm not getting what I hopped to get so I'm doubt I am.
Why doesn't what I have work, and how I would go about fixing it?
If I am supposed to put glOrtho
in a specific place it would be helpful to know where.
Also, as I am supposed to have several viewports will all of the viewports have an orthographic projection after that?
Here's my entire program code snipet is taken from lines 192-204
I don't have full knowledge of your program, but given what I see, I doubt glOrtho will work at all. It is a (deprecated) function used to multiply the current matrix in the fixed function pipeline by an orthographic projection matrix. However, your program appears to use shaders and construct its own matrices (as a modern OpenGL program should). So if what you currently have sans glOrtho works, what you really need to do is replace your mat4 persp_proj
with a mat4 ortho_proj
that contains the orthographic projection you want.