glutIdleFunc()

更新时间:2023-05-05 03:17

glutIdleFunc设置全局的回调函数,当没有窗口事件到达时,GLUT程序功能可以执行后台处理任务或连续动画。如果启用,这个idle function会被不断调用,直到有窗口事件发生。回调函数没有参数。当前的窗口和菜单在执行idle func之前不会改变。当程序依赖多窗口或菜单时最好不要依赖于当前设定。

用法

void glutIdleFunc(void (*func)(void));

说明

英文

glutIdleFunc sets the global idle callback to be func so a GLUT program can perform background processing tasks or continuous animation when window system events are not being received. If enabled, the idle callback is continuously called when events are not being received. The callback routine has no parameters. Thecurrent windowandcurrent menuwill not be changed before the idle callback. Programs with multiple windows and/or menus should explicitly set thecurrent windowand/orcurrent menuand not rely on its current setting.

The amount of computation and rendering done in an idle callback should be minimized to avoid affecting the program's interactive response. In general, not more than a single frame of rendering should be done in an idle callback.

assing NULL to glutIdleFunc disables the generation of the idle callback.

中文

应尽量减少在空闲回调完成的计算和渲染的数额,以避免影响程序的交互响应。在一般情况下,不超过单帧的渲染工作应在一个空闲回调。

glutIdleFunc传递NULL(0)就可禁用其函数回调。

在glutIdleFunc(void (*func)(void))回调函数中指定一个函数,如果不存在其他尚未完成的事件(例如,当事件循环处于空闲的时候),就执行这个函数。这个回调函数接受一个函数指针作为它的唯一参数。如果向它传递NULL(0),就相当于禁用这个函数。

程序示例

免责声明
隐私政策
用户协议
目录 22
0{{catalogNumber[index]}}. {{item.title}}
{{item.title}}