title: Moving Shape via Mouse in Opengl
body: <pre><code>void Rectangle(void) { 
  
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_QUADS);
      glColor3f(1.0,0.0,0.0);
      glVertex2f(m_x-0.25,m_y-0.25);
      glColor3f(1.0,0.0,0.0);
      glVertex2f(m_x-0.25,m_y-0.75);
      glColor3f(1.0,0.0,0.0);
      glVertex2f(m_x-0.75,m_y-0.75);
      glColor3f(1.0,0.0,0.0);
      glVertex2f(m_x-0.75,m_y-0.25);
  glEnd();
  glutSwapBuffers();
  </code></pre>
  
  <p>I want to move the rectangle to where pressed mouse. m_x and m_y are global variable.This function has called in main glutDisplayFunc(Rectangle), mouse function like this: </p>
  
  <pre><code>void mouse(int button,int state,int x,int y)  
    switch(button)
  {
  case GLUT_LEFT_BUTTON:
      if(state==GLUT_DOWN)
      {
          m_x=x;
          m_y=y;
          Rectangle();
          glutSwapBuffers();
      }
      break;
  
  default:
      break;
  
  }
  </code></pre>
  
  <p>When the application runs ,it draws a rectangle after i pressed mouse the rectangle lost.What is my wrong?</p>