openglvisual-c++glutfreeglutglu

Real - time points plotting using opengl VC++


I need suggestion on how to plot points real-time. Using OpenGL Right now what am doing is loading the desired data from a csv to an array and plotting the points from there. This is working fine.

What I intend to do is, load such multiple csv's one by one at regular intervals of time, so that i can create a animation kind of output. I can do this but once the program plots the point by entering glutMainLoop();, it never gets out without closing opengl window. I want to load the 1st csv, show it in OpenGL window, then load the next csv and show the new set of points and so on.

If its difficult to comprehend, just see the image below

enter image description here

Just consider the red and blue points.Consider them as not actually moving but being plotted from an external data with each new postions loaded from the csv file. Hope its clear


Solution

  • [...] once the program plots the point by entering glutMainLoop();, it never gets out without closing opengl window.

    freeglut extends glut by glutLeaveMainLoop and glutMainLoopEvent.

    e.g.:

    bool condtion = true;
    while (condtion)
    {
        glutMainLoopEvent(); // handle the main loop once
        glutPostRedisplay(); // cause `display` to be called in `glutMainLoopEvent`
    
        condtion = ...;
    }
    

    Another option would be to use glutIdleFunc to do additional stuff. So it is not necessary to leave the glut main loop at all..