What if we don't mention Modelview and projection matrix? 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()
{
    glClear(GL_COLOR_BUFFER_BIT);

    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 ); 
       glEnd();
    glFlush();
}

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

    glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);

    glutInitWindowSize(500,500);

    glutInitWindowPosition(0,0);

    glutCreateWindow("First Program");

    glutDisplayFunc(Di);
    glutMainLoop();
}
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


Tutorial 3 : Matrices | opengl-tutorial.org
Coordinate Systems | LearnOpenGL.com
OpenGL Projection Matrix | songho.ca