title: Difference between glMatrixMode(GL_PROJECTION) and glMatrixMode(GL_MODELVIEW)
body: <p>What's the difference between <code>glMatrixMode(GL_PROJECTION)</code> and <code>glMatrixMode(GL_MODELVIEW)</code>?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glut.h&gt;
  
  #define KEY_ESCAPE 27
  
  void display();
  void keyboard(unsigned char,int,int);
  
  int main(int argc, char **argv) {
      glutInit(&amp;argc, argv);                                    
      glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH );
      glutInitWindowSize(600,400);                  
      glutCreateWindow(&quot;Opengl Test&quot;);                              
      glutDisplayFunc(display);
      glutKeyboardFunc(keyboard);
      glutMainLoop();
      return 0;
  }
  void display() {
      float x,y,z;
      int i;
      x=0;
      y=-0.8;
      z=0;
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glClear(GL_COLOR_BUFFER_BIT);
      glColor3f(1,1,0);
      glBegin(GL_POINTS);
      for(i=0;i&lt;98;i++) {
          glVertex3f(x,y,z);
          x=x+0.01;
      }
      glEnd();
      glutSwapBuffers();    
  }
  void keyboard(unsigned char key, int mousePositionX, int mousePositionY) {
      switch ( key ) {
          case KEY_ESCAPE:
              exit ( 0 );  
              break;      
          default:      
              break;
      }
  }
  </code></pre>
  <p>Example 2:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glut.h&gt;
  
  #define KEY_ESCAPE 27
  
  void display();
  void keyboard(unsigned char,int,int);
  
  int main(int argc, char **argv) {
      glutInit(&amp;argc, argv);                                    
      glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH );
      glutInitWindowSize(600,400);                  
      glutCreateWindow(&quot;Opengl Test&quot;);                              
      glutDisplayFunc(display);
      glutKeyboardFunc(keyboard);
      glutMainLoop();
      return 0;
  }
  void display() {
      float x,y,z;
      int i;
      x=0;
      y=-0.8;
      z=0;
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glClear(GL_COLOR_BUFFER_BIT);
      glColor3f(1,1,0);
      glBegin(GL_POINTS);
      for(i=0;i&lt;98;i++) {
          glVertex3f(x,y,z);
          x=x+0.01;
      }
      glEnd();
      glutSwapBuffers();    
  }
  void keyboard(unsigned char key, int mousePositionX, int mousePositionY) {
      switch ( key ) {
          case KEY_ESCAPE:
              exit ( 0 );  
              break;      
          default:      
              break;
      }
  }
  </code></pre>
  <p>For both codes, I got the same result.
  Can anyone show the difference of these <code>glMatrixMode(GL_MODELVIEW)</code> and <code>glMatrixMode(GL_PROJECTION)</code>?</p>