且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在另一个无限循环中使用一个无限循环生成的值?

更新时间:2022-06-02 22:29:24

您需要单独的线程或进程来执行此操作.为什么需要无限循环?您为什么不想使用单独的线程?
You need separate threads or processes to do this. Why the need for infinite loops? Why don''t you want to use separate threads?


glutMainLoop是OpenGL过多应用程序的主事件循环.您只需要调用一次即可.

您需要定义一个回调函数(通常用于显示),该函数将从glutMainLoop函数(使用glutDisplayFunc)内部进行调用.

当进程处于中间时,您还需要定义另一个回调函数(使用glutIdleFunc).

正是在该函数中,您应该更新球体的半径,并且该半径将(应该吗?)将在显示函数中用于以适当的半径重新绘制球体.

(主要受 http://www.lighthouse3d.com/tutorials/glut-tutorial/ [ ^ ])
glutMainLoop is the main event loop of a glut OpenGL application; you just have to call it once.

You need to define a callback function (usually for the display) that will be called internally from the glutMainLoop function (with the glutDisplayFunc).

You will also need to define another callback function when the process is iddle, (use glutIdleFunc).

It is in that function that you should update the radius of the sphere, and that radius will (should?) be used in the display function to redraw the sphere with the appropriate radius.

(mostly inspired from http://www.lighthouse3d.com/tutorials/glut-tutorial/[^])