title: Updating a graph through C++ and GLUT
body: <p>I have written a c++ program in Xcode to implement Symbolic Regression &amp; Genetic Programming. I'd like to create a window to visualize the reference data (an array of 2d points) and the best function that the program generates each generation.</p>
  
  <p>To put it simply, I'd like the window to show 2 graphs, and have it be updated with a for loop. From what I understand, GLUT seems like a good framework, and I've written a function to display the reference data (std::vector is how I'm storing the "referenceDataSet" variable):</p>
  
  <pre><code>void renderScene(){
      // The min/max variables are just for scaling &amp; centering the graph
      double minX, maxX, minY, maxY;
      minX = referenceDataSet[0].first;
      maxX = referenceDataSet[0].first;
      minY = referenceDataSet[0].second;
      maxY = referenceDataSet[0].second;
      for (int i = 0; i &lt; referenceDataSet.size(); i++) {
          minX = min(minX, referenceDataSet[i].first);
          maxX = max(maxX, referenceDataSet[i].first);
          minY = min(minY, referenceDataSet[i].second);
          maxY = max(maxY, referenceDataSet[i].second);
      }
      glLoadIdentity ();
      glClear(GL_COLOR_BUFFER_BIT);
      glBegin( GL_LINE_STRIP );
      glColor4f( 1.0, 0.0, 0.0, 1.0);
      for (int i = 0; i &lt; referenceDataSet.size(); i++) {
          glVertex2f((referenceDataSet[i].first-minX)/(maxX-minX)-0.5, (referenceDataSet[i].second-minY)/(maxY-minY)-0.5);
      }
      glEnd();
      glFlush();
  }
  
  void renderInit(int argc, char **argv){
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowSize(600, 600);
      glutCreateWindow("");
      glutDisplayFunc(renderScene);
      glutCheckLoop();
  }
  </code></pre>
  
  <p>The problem with this is that I'm not sure how I should go about updating the window, or drawing a second graph that constantly changes.</p>
  
  <p>Also, this is my first question on Stack Overflow, so I apologize if I'm not doing something correctly here, or if any of this is difficult to understand. I searched as best I could for the answer, but couldn't really find anything relevant.</p>