(OpenGL) Line is drawn but shapes are not
<p>I'm currently learning OpenGL and from what I understood, I have to call </p>

<pre><code>glMatrixMode(GL_PROJECTION);
glLoadIdentity();
</code></pre>

<p>before drawing lines. Then, to draw shapes I need to call </p>

<pre><code>glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
</code></pre>

<p>to draw shapes such as GL_TRIANGLES and GL_QUADS.
I wrote this code with the goal of drawing a single line at top and 3 shapes, but only the line was drawn.
Here is my code.</p>

<pre><code>void drawScene() {
//Clear information from last draw
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective



glBegin(GL_LINES);

glColor3f(100,200,100);
glLineWidth(10.0f);
glVertex2f(-1.0f,0.8f);
glVertex2f(1.0f,0.8f);

glEnd();

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS); //Begin quadrilateral coordinates

//Trapezoid
glVertex3f(-0.7f, -1.5f, -5.0f);
glVertex3f(0.7f, -1.5f, -5.0f);
glVertex3f(0.4f, -0.5f, -5.0f);
glVertex3f(-0.4f, -0.5f, -5.0f);

glEnd(); //End quadrilateral coordinates


glBegin(GL_TRIANGLES); //Begin triangle coordinates

//Pentagon
glVertex3f(0.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(0.5f, 1.0f, -5.0f);

glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);

glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.5f, -5.0f);

//Triangle
glVertex3f(-0.5f, 0.5f, -5.0f);
glVertex3f(-1.0f, 1.5f, -5.0f);
glVertex3f(-1.5f, 0.5f, -5.0f);

glEnd(); //End triangle coordinates

glutSwapBuffers(); //Send the 3D scene to the screen
}
</code></pre>

<p>Could someone please explain to me how to switch between GL_PROJECTION and GL_MODELVIEW and how do they work?</p>