【问题标题】:Real - time points plotting using opengl VC++使用 opengl VC++ 绘制实时点
【发布时间】:2019-12-19 06:12:14
【问题描述】:

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

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

如果难以理解,请看下图

只需考虑红点和蓝点。将它们视为实际上并未移动,而是从外部数据绘制的,每个新位置都从 csv 文件加载。希望清楚

【问题讨论】:

  • “一旦程序通过输入 glutMainLoop(); 绘制点,它就永远不会在不关闭 opengl 窗口的情况下退出。” - freeglut 将 glut 扩展为 glutLeaveMainLoopglutMainLoopEvent.
  • 是的,我用过glutMainLoopEvent,但它似乎妨碍了我的glutMotionFunc。使用glutMainLoop(),我可以单击并拖动场景。使用循环事件,不会发生拖动/平移。我将 glutMainLoopEvent 作为最后的手段。

标签: opengl visual-c++ glut freeglut glu


【解决方案1】:

[...] 一旦程序通过输入 glutMainLoop(); 绘制点,它永远不会在不关闭 opengl 窗口的情况下退出。

freeglut 将过剩扩展到 glutLeaveMainLoopglutMainLoopEvent

例如:

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

    condtion = ...;
}

另一种选择是使用glutIdleFunc 来做其他事情。所以根本没有必要离开 glut 主循环..

【讨论】:

  • 谢谢,使用glutPostRedisplay(); 允许我使用glutMainLoopEvent 而不会丢失我当前的设置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多