title: How to display the 3D point from text file by using Opengl library
body: <p>I would like to plot 3D point specified by the value from column[0] in text file. For example, column[0] equals to 2,then displays 3D point(xyz) following these: (1.529, 0.25,-2.038 ), (1.530,0.253,-2.040), (1.530,0.253,-2.044)</p>
  <p>test.txt</p>
  <blockquote>
  <p>1 1.529 0.253 -2.038</p>
  <p>1 1.529 0.253 -2.038</p>
  <p>2 1.529 0.253 -2.038</p>
  <p>2 1.530 0.253 -2.040</p>
  <p>2 1.530 0.253 -2.044</p>
  <p>3 1.532 0.254 -2.038</p>
  <p>3 1.533 0.255 -2.036</p>
  <p>3 1.533 0.255 -2.036</p>
  <p>3 1.534 0.255 -2.036</p>
  <p>3 1.534 0.255 -2.036</p>
  </blockquote>
  <p>This is my code</p>
  <pre><code>#include &lt;Windows.h&gt; 
  #include &lt;GL\glew.h&gt; 
  #include &lt;GL\freeglut.h&gt; 
  #include &lt;stdio.h&gt; 
  #include &lt;vector&gt; 
  #include &lt;stdlib.h&gt; 
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  char title[] = &quot;Point&quot;;
  
  void initGL() {
      glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black 
      glClearDepth(1.0f);                   // Set background depth to farthest
      glEnable(GL_DEPTH_TEST);   // Enable depth testing for z-culling
      glDepthFunc(GL_LEQUAL);    // Set the type of depth-test
      glShadeModel(GL_SMOOTH);   // Enable smooth shading
      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);  
  }
  
  void display() {
  
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers
      glMatrixMode(GL_MODELVIEW);     // To operate on model-view matrix
      glLoadIdentity();                 // Reset the model-view matrix
      glTranslatef(1.5f, 0.0f, -7.0f);  // Move right and into the screen
  
      vector&lt;vector&lt;double&gt;&gt; tempdouble;
      ifstream in(&quot;test.txt&quot;);
      string line;
  
      double Dstage1x = 0.0;  
      double Dstage1y = 0.0;
      double Dstage1z = 0.0;
      double Dstage2x = 0.0;
      double Dstage2y = 0.0;
      double Dstage2z = 0.0;
      double Dstage3x = 0.0;
      double Dstage3y = 0.0;
      double Dstage3z = 0.0;
      int ii = 0;
      int stage1 = 0;
      int stage2 = 0;
      int stage3 = 0;
  
      while (std::getline(in, line))
      {
          tempdouble.push_back(vector&lt;double&gt;());
          stringstream ss(line);
          double num;
          while (ss &gt;&gt; num)
          {
              tempdouble.back().push_back(num);
          }
      }
  
      for (int i = 0; i &lt; tempdouble.size(); i++)
      {
          for (int j = 0; j &lt; tempdouble[i].size(); j++)
          {
  
              int st1_x=0; int st1_y=0; int st1_z=0;
              int st2_x=0; int st2_y=0; int st2_z=0;
              int st3_x=0; int st3_y=0; int st3_z=0;
  
              if(tempdouble[i][0]==1 )
              {
  
                  glPointSize(5);glColor3f(1.0f, 0.5f, 0.0f); 
                  glBegin(GL_POINTS); 
  
  
                  st1_x += Dstage1x*0;  st1_y += Dstage1y*0; st1_z += Dstage1z*0;   //set value 
                  Dstage1x = st1_x + tempdouble[i][1];
                  Dstage1y = st1_y + tempdouble[i][2];
                  Dstage1z = st1_z + tempdouble[i][3];
                  stage1++;
                  //cout &lt;&lt;&quot;Check tempdouble[i][0] state1 : &quot; &lt;&lt; tempdouble[i][0] &lt;&lt;&quot;\t&quot;&lt;&lt;endl;
  
                  cout &lt;&lt; &quot;state1(xyz) : &quot; &lt;&lt; &quot;( &quot; &lt;&lt; Dstage1x &lt;&lt; &quot; ,&quot; &lt;&lt; Dstage1y &lt;&lt; &quot;,&quot; &lt;&lt; Dstage1z &lt;&lt; &quot;)&quot;&lt;&lt; endl;
                  glVertex3f(Dstage1x, Dstage1y, Dstage1z);
                  //glVertex3f(tempdouble[i][1], tempdouble[i][2], tempdouble[i][3]);
                  //glVertex3f(tempdouble[i][j], tempdouble[i][j], tempdouble[i][j]);
                  glEnd();
                  break;
  
              }
  
              if (tempdouble[i][0] == 2) {
  
                  glPointSize(5);glColor3f(0.0f, 0.0f, 1.0f);  
                  glBegin(GL_POINTS); 
  
                  st2_x += Dstage2x * 0;  st2_y += Dstage2y*0; st2_z += Dstage2z*0;   //set value 
  
                  Dstage2x = st2_x + tempdouble[i][1];
                  Dstage2y = st2_y + tempdouble[i][2];
                  Dstage2z = st2_z + tempdouble[i][3];
                  stage2++;
                  cout &lt;&lt; &quot;state2(xyz) : &quot; &lt;&lt; &quot;( &quot; &lt;&lt; Dstage2x &lt;&lt; &quot; ,&quot; &lt;&lt; Dstage2y &lt;&lt; &quot;,&quot; &lt;&lt; Dstage2z &lt;&lt; &quot;)&quot;&lt;&lt; endl;
  
                  glVertex3f(Dstage2x,Dstage2y,Dstage2z);
                  //glVertex3f(tempdouble[i][1], tempdouble[i][2], tempdouble[i][3]);
                  //glVertex3f(tempdouble[i][j], tempdouble[i][j], tempdouble[i][j]);
                  glEnd();    
                  break;
              }
  
              if (tempdouble[i][0] == 3) {
                  glPointSize(5); glColor3f(1.0f, 0.0f, 0.0f);   
                  glBegin(GL_POINTS); 
  
  
                  st3_x += Dstage3x*0;  st3_y += Dstage3y*0; st3_z += Dstage3z*0;   //set value 
  
                  Dstage3x = st3_x + tempdouble[i][1];
                  Dstage3y = st3_y + tempdouble[i][2];
                  Dstage3z = st3_z + tempdouble[i][3];
                  stage3++;
                  cout &lt;&lt; &quot;state3(xyz) : &quot; &lt;&lt; &quot;( &quot; &lt;&lt; Dstage3x &lt;&lt; &quot; ,&quot; &lt;&lt; Dstage3y &lt;&lt; &quot;,&quot; &lt;&lt; Dstage3z &lt;&lt; &quot;)&quot;&lt;&lt; endl;
  
                  glVertex3f(Dstage3x,Dstage3y,Dstage3z);
                  //glVertex3f(tempdouble[i][0],tempdouble[i][1],tempdouble[i][2]);
                  //glVertex3f(tempdouble[i][j], tempdouble[i][j], tempdouble[i][j]);
                  glEnd();
                  break;
              }
  
          }
  
      }
      cout &lt;&lt; &quot;stage 1: &quot;&lt;&lt; stage1 &lt;&lt; endl;
      cout &lt;&lt; &quot;stage 2: &quot;&lt;&lt;stage2 &lt;&lt; endl;
      cout &lt;&lt; &quot;stage 3: &quot;&lt;&lt;stage3 &lt;&lt; endl;
      glutSwapBuffers();  // Swap the front and back frame buffers (double buffering)
  }
  
  void reshape(GLsizei width, GLsizei height) {  // GLsizei for non-negative integer
      // Compute aspect ratio of the new window
      if (height == 0) height = 1;                // To prevent divide by 0
      GLfloat aspect = (GLfloat)width / (GLfloat)height;
  
      // Set the viewport to cover the new window
      glViewport(0, 0, width, height);
  
      // Set the aspect ratio of the clipping volume to match the viewport
      glMatrixMode(GL_PROJECTION);  // To operate on the Projection matrix
      glLoadIdentity();             // Reset
      // Enable perspective projection with fovy, aspect, zNear and zFar
      gluPerspective(45.0f, aspect, 0.1f, 100.0f);
  }
  void changeViewPort(int w, int h)
  {
      glViewport(0, 0, w, h);
  }
  
  void render()
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glutSwapBuffers();
  }
  int main(int argc, char* argv[]) {
  
      void display();
  
      glutInit(&amp;argc, argv);            // Initialize GLUT
      glutInitDisplayMode(GLUT_DOUBLE); // Enable double buffered mode
      glutInitWindowSize(640, 480);   // Set the window's initial width &amp; height
      glutInitWindowPosition(50, 50); // Position the window's initial top-left corner
      glutCreateWindow(title);          // Create window with the given title
      glutDisplayFunc(display);       // Register callback handler for window re-paint event
      glutReshapeFunc(reshape);       // Register callback handler for window re-size event
      initGL();                       // Our own OpenGL initialization
      glutMainLoop();       
  
      return 0;
  }
  </code></pre>
  <p>My problem is that the point shown in the wrong position. It is impossible that column[0](equal to 1,2,3) have all the same points.Can someone help me with this</p>