如何在另一个无限循环中使用一个无限循环生成的值? [英] How to use values generated by one infinite loop in another infinite loop?

查看:124
本文介绍了如何在另一个无限循环中使用一个无限循环生成的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个无限循环.
它们都必须同时运行.

当我调用一个无限循环时.而已.我被困住了;我无法调用另一个无限循环.

是否有另一种方法可以解决此问题,然后有2个线程",每个线程运行一个循环?

谢谢您的帮助.

Hi,

I have two infinite loops.
They both have to be running at the same time.

When i call one infinite loop. That''s it. I''m stuck; I can not call the other infinite loop.

Is there another way to solve this problem then having 2 "threads", each running one loop?

Thank you for your help.

推荐答案

您需要单独的线程或进程来执行此操作.为什么需要无限循环?您为什么不想使用单独的线程?
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/[^])


这篇关于如何在另一个无限循环中使用一个无限循环生成的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆