So I've been learning opengl for some weeks now and managed to understand all the viewing pipelines. As far my understanding goes we need to bring the object to world space and then the world space to view space. After that the clipping is done by any of the two projections as we want. The clipping volume is then sent to the viewport which is mapped to the screen coordinates.

Now when I write this simple basic code below I don't use any of the matrixmode (GL_MODElVIEW or GL_PROJECTION) but still the primitive is displayed on the screen. So what am I missing here?

and also an extension to this question I would also like to know what exactly means to bring the object to world coordinates in theory. Does it means overlapping the axes of the object coordinates with the world coordinates.

With lot of opengl discussions out there I don't know where to look. Would be extra nice if someone refer me to some good articles.

void Di()

    glBegin(GL_QUADS) ;           
       glColor3f ( 1.0, 0.3, 0.2);     
        glVertex2f( -0.1, -0.1 );       
        glVertex2f(  0.1, -0.1 );       
        glVertex2f(  0.1,  0.1 ); 
        glVertex2f( -0.1,  0.1 ); 

int main( int argc, char** argv)
    glutInit( &argc, argv);




    glutCreateWindow("First Program");

  • 2
    $\begingroup$ Also just for your information you are learning legacy OpenGL which is obsolete since 2008. Since your spending effort in learning atleast go and learn relevant OpenGL. No you do not nedd matrices but the alternative is more painful. $\endgroup$
    – joojaa
    Commented Sep 28, 2016 at 14:48
  • $\begingroup$ I didn't know that but anyway the legacy OpenGL is a manadatory course for me. But I will most certainly learn the new one. $\endgroup$
    – Broskiee
    Commented Sep 29, 2016 at 6:03
  • 1
    $\begingroup$ Like I said I've been learning opengl for a few weeks now and since it is a one year course I definately believe I will get to opengl4.5 later . And It is not weird at all because University education also focus on teaching older stuff along with the newer stuff. $\endgroup$
    – Broskiee
    Commented Sep 29, 2016 at 7:09
  • 1
    $\begingroup$ No, it's definitely not ok. There is no concepts that the old way does that the new way does not do. Theres absolutely no need for you to learn how to send data and use fixed pipeline programming, it does not even change all that much. In fact if you were not using the fixed pipeline you wouldn't have this question. All your doing is learning an API that nolonger should be used, i mean ist fine if you learned how to blit colors on a c64 also in the course bit other than that no benefit, other than perhaps knowing the difference. $\endgroup$
    – joojaa
    Commented Sep 29, 2016 at 7:21
  • 1
    $\begingroup$ you know what I'm gonna leave you to argue that with the education board. $\endgroup$
    – Broskiee
    Commented Sep 29, 2016 at 7:26

1 Answer 1


Your screen isn't 3D, so how do you display 3D objects on it? You need to map 3D coordinates into 2D space. This also explains why your OpenGL code is not behaving how you're expecting it to. Sorry if parts of this answer are things you already know (just trying to be comprehensive).

What do the model view and projection matrices do?

The model view matrix is actually two matrices (multiplied together): the model matrix and the view matrix. This is important to understanding because these are two transformations into different spaces.

The model matrix transforms model space into world space. This means that say you have a vertex is at an offset from the center of a model. If you want that vertex to be in world space, it must use the scale, rotation, and position of the model to determine this. The model matrix accomplishes this.

The view matrix transforms the world space into the camera space. Does world move or does the camera move in a 3D application? Well, actually the world moves around the camera. The camera is always at the origin, so the view matrix moves the world to this point.

The projection matrix might be the trickiest to visualize. Screens are 2D (technicalities aside), so how do we show 3D objects here? A projection matrix converts 3D coordinates into 2D coordinates (with depth, so still technically 3D). You end up with Normalized Device Coordinates (NDCs). Each vertex on screen is represented by three values: * x (horizontal) ranging from [-1, 1] * y (vertical) ranging from [-1, 1] * z (depth) ranging from [-1, 1]

Why don't you need model-view and projection matrices?

It's not that you don't need them, it's just that you are using as explained in the last step above. Otherwise, you are effectively just rendering 2D graphics. Right now you are drawing a quad.

Look at the coordinates that you are providing. You are basically treating the vertices as 2D vertices for 2D graphics since you are directly specifying their coordinates in NDC space. Remember, the coordinates you picked are between -1 and 1 for x and y, so you are effectively treating them as NDCs. You directly send them to the rasterizer in your example.

Further Reading


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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