title: why not display in openGL?
body: <pre><code>int main(int argc,char * argv[]){
      srand(time(NULL));
      glutInit(&amp;argc,argv);
  
      // Setup GLUT
      glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB     | GLUT_DEPTH | GLUT_STENCIL);
      glutInitWindowSize (window_width,window_height);
      glutCreateWindow (window_title);
      graphics_init ();
  
      // Initialize Runtime variables
      initialize();
  
      // callbacks
      glutReshapeFunc(&amp;reshape);
      glutDisplayFunc(&amp;display);
      glutMouseFunc(&amp;mouse);
      glutMainLoop();
      return 0;
  }
  
  
  void mouse(int button, int state, int x, int y ){
      if(state == GLUT_DOWN){
           draw_method_two(); // draw objects here using method 2
              glFlush();
  
      }else{
          current_point_i = -1;
      }
  }
  
  void display(){
      // Clear Viewport
      glClearColor(0.0f,0.0f,0.0f,1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      draw_method_one(); ///// using method 1 to draw objects
  
      glFlush();
      glutSwapBuffers();
  
  }
  </code></pre>
  
  <p>There are two methods to draw objects. in <code>mouse()</code>, <code>draw_objects_two</code> is used to draw the objects when mouse is clicked.  However, the objects shown in the window are still created by <code>draw_method_one</code>. I use <code>glFlush</code> in the <code>mouse()</code>function. but why it is not displayed in screen?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>from this <a href="https://stackoverflow.com/questions/4206472/understanding-the-relationship-between-glutdisplayfunc-and-glutpostredisplay">link</a>, it says: </p>
  
  <p><code>The function you pass to glutDisplayFunc is only called it is needed: that means when the window is resized, or when an another window has hidden it. If you use glutMouseFunc, for instance, you perhaps want to update (redraw) your window content according to that clic. Also, if you draw animations, you need to call glutPostRedisplay from your idle function.</code></p>
  
  <p>So why <code>glutDisplayFunc()</code> is called in this case?</p>