title: draw a line with open gl mouse function using dda/bresenham algorithm
body: <p>So i have to draw a line using mouse function. When the mouse clicks two points, the program needs to draw a line connecting them.</p>
  
  <p>I need to make an imaginary 10x10 array and map the points on it and then connect the dots. window size doesn't matter.</p>
  
  <p>I have no clue about what to do about the imaginary array and how to save the mouse coordinates so i can us them. Help</p>
  
  <pre><code>#include &lt;glut.h&gt;
  #include&lt;stdio.h&gt;
  
  void RenderScene(void) //점
  {
      glClear(GL_COLOR_BUFFER_BIT);
      // Flush drawing commands
      glFlush();
  }
  
  
  void SetupRC(void) //바탕
  {
      // setup clear color
      glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
  }
  
  
  void ChangeSize(GLsizei w, GLsizei h) {
          GLfloat  aspectRatio;
          // Prevent a divide by zero
          if (h == 0)
              h = 1;
          // Set Viewport to window dimensions
          glViewport(0, 0, w, h);
          // Reset coordinate system
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          // Establish clipping volume (left, right, bottom, top, near, far)
          aspectRatio = (GLfloat)w / (GLfloat)h;
          glOrtho(0, w, h, 0, 1.0, -1.0); 
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
  }
  
  
  void myRectf(GLfloat    x1, GLfloat     y1, GLfloat     x2, GLfloat     y2){
      glPointSize(10);
  
      ////ddaLine
  
      int dx, dy;
      int m = (y2 - y1) / (x2 - x1);
      for (int i = x1; i &lt;= x2; i++)
      {
          if (m &lt;= 1)
          {
              dx = 1;
              dy = m * dx;
          }
          else
          {
              dy = 1;
              dx = dy / m;
          }
          x1 += dx;
          y1 += dy;
  
          glBegin(GL_POINTS);
          glVertex3f(x1, y1, 0.f);
          glEnd();
      }
  
      /////breline
      while (x1 &lt; x2)
      {
          int dx = x2 - x1;
          int dy = y2 - y1;
          int di = 2 * dy - dx;
          int ds = 2 * dy;
          int dt = 2 * (dy - dx);
  
          x1++;
          if (di &lt; 0)
              di += ds;
          else
          {
              y1++;
              di += dt;
          }
          glBegin(GL_POINTS);
          glVertex3f(x1, y1, 0.f);
          glEnd();
      }
  }
  
  GLfloat g_x = -1000.f, g_y = -1000.f;
  
  void MouseHandler(int button, int state, int x, int y){
      if (button == GLUT_LEFT_BUTTON
          &amp;&amp; state == GLUT_DOWN){
          g_x = x; g_y = y;
          printf("%d,%d \n", x, y);
      }
      glutPostRedisplay();
  }
  
  
  void main(int argc, char* argv[]){
      int array[10][10];
  
      glutInit(&amp;argc, argv); // initialize GL context
      // single or double buffering | RGBA color mode
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
      glutCreateWindow("Lec01");
      // callback function
      glutDisplayFunc(RenderScene);
      glutReshapeFunc(ChangeSize);
  
      SetupRC();          // initialize render context(RC)
      glutMouseFunc(MouseHandler);
  
      glutMainLoop();     // run GLUT framework
  }
  </code></pre>
  
  <p>And I'm not allowed to use GL_LINES</p>