title: OpenGL Glut Drawing Points Not Working
body: <p>Can someone help me out in checking my code? I'm trying to draw a simple dot by clicking in the window, but I can't see any points drawn. The point recording system is copied as an example from one of the stack overflow posts.</p>
  
  <pre class="lang-cplusplus prettyprint-override"><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  //#include &lt;GL\glew.h&gt;
  #include &lt;gl/glut.h&gt;
  //#include &lt;GL\freeglut.h&gt;
  #include &lt;math.h&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include "draw.h"
  
  //DRAW draw2;
  
  class Point
  {
      int Xvalue, Yvalue;
      std::string Text;
  public:
      void xy(int x, int y)
      {
          Xvalue = x;
          Yvalue = y;
      }
  
      void text(std::string text)
      {
          Text = text;
      }
  
      //return individual x y value
      int x() { return Xvalue; }
      int y() { return Yvalue; }
  
      //return text value
      std::string rtext() { return Text; }    
  };
  
  Point point[30];
  int count = 0;
  
  
  void Init()
  {
      glClearColor(1.0, 1.0, 1.0, 0.0);
      //glColor3f(0.0, 0.0, 0.0);
      //glPointSize(5);
  
      glMatrixMode(GL_PROJECTION);    //coordinate system
      //glLoadIdentity();
      gluOrtho2D(0.0, 1200.0, 0.0, 800.0);
  }
  
  
  void Display()
  {
      glClear(GL_COLOR_BUFFER_BIT); // clear display window
      glColor3f(1.0, 1.0, 1.0);
      //glLoadIdentity();
  
      /*Drawing here*/
      //redraw 
      for (int i = 0; i &lt; count; i++)
      {
          int x = point[i].x();
          int y = point[i].y();
  
          //draw2.Dot(x, y);
          std::cout &lt;&lt; "drawing dot " &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; std::endl;
          glBegin(GL_POINTS);
              glColor3f(0.3, 0.3, 0.3);
              glPointSize(5.0f);
              glVertex2i(x, glutGet(GLUT_WINDOW_HEIGHT) - y);
          glEnd();    
      }
      glFlush();
  }
  
  
  void mouse(int button, int state, int x, int y)
  {       
      if (button == GLUT_LEFT_BUTTON &amp;&amp; state == GLUT_DOWN)
      {       
          point[count].xy(x, y);
          //draw2.Dot(x, y);
          count++;    
      }    
      glutPostRedisplay();
  }
  
  
  int main(int argc, char *argv[])
  {
      glutInit(&amp;argc, argv);                          //initialize toolkit
                                                      //Request double buffered true color window with Z-buffer
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );   //display mode
      glutInitWindowSize(1200, 800);                  //set window size
      glutCreateWindow("NURBS Curve");                //open screen window
  
      Init(); //additional initializations
  
      //CALLBACK FUNCTIONS
      glutMouseFunc(mouse);
      glutDisplayFunc(Display);   //send graphics to display window    
      /*
      GLenum err = glewInit();
      if (GLEW_OK != err)
      {
          fprintf(stderr, "GLEW error");
          return 1;
      }
      */    
      //pass control to glut for events, loops
      glutMainLoop();
      return 0;
  }
  </code></pre>