使用 opengl VC++ 实时绘制点

Real - time points plotting using opengl VC++

我需要有关如何实时绘制点的建议。使用 OpenGL 现在正在做的是将所需数据从 csv 加载到数组并从那里绘制点。这工作正常。

我打算做的是,以固定的时间间隔一个一个地加载这样的多个 csv,这样我就可以创建一种动画输出。我可以这样做,但是一旦程序通过输入 glutMainLoop(); 绘制点,它就不会在不关闭 opengl window 的情况下退出。我想加载第一个 csv,在 OpenGL 中显示它 window,然后加载下一个 csv 并显示新的点集等等。

如果难以理解,请看下图

只需考虑红色和蓝色 points.Consider 它们实际上并没有移动,而是根据外部数据绘制的,每个新位置都从 csv 文件加载。希望它清楚

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

freeglut 将过剩扩大 glutLeaveMainLoopglutMainLoopEvent

例如:

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

    condtion = ...;
}

另一个选择是使用 glutIdleFunc 做额外的事情。所以完全没有必要离开过剩的主循环..