Graphics 版 (精华区)

发信人: dcs (euraka), 信区: Graphics
标  题: Motif&Opengl(8)
发信站: 紫 丁 香 (Mon Mar 29 21:44:44 1999), 转信

3 Animation Via Work Procedures

The X Toolkit's work procedure facility makes it easy to integrate continuous OpenGL animation with Motif user interface
operation. Work procedures are application supplied routines that execute while the application is idle waiting for events.
Work procedures should be used to do small amounts of work; if too much time is spent in a work procedure, X events will
not be processed and program interactivity will suffer. 

Rendering a single frame of OpenGL animation is a good use for work procedures. XtAppAddWorkProc and
XtRemoveWorkProc are used to add and remove work procedures. XtAppAddWorkProc is passed a function pointer for the
routine to be called as a work procedure. The function to be called returns a Boolean. If the function returns True, the work
procedure should be removed automatically; returning False indicates the work procedure should remain active.
XtAppAddWorkProc returns an ID of type WorkProcId which can later be given to XtRemoveWorkProc to remove the work
procedure. 

The paperplane example uses a work procedure to manage the update of its 3D scene. In response to changing the state of
the ``Motion'' toggle button on the ``Planes'' pulldown menu, the toggle callback routine will add and remove the animate
work procedure. 

The animate routine calls tick which advances the position of each active plane; animate then calls draw to redraw the
scene with the new plane locations. Finally, animate returns False to leave the work procedure installed so that the animation
will continue. 

Because paperplane uses a work procedure, animation of the scene does not interfere with window resizing and user input.
The X Toolkit manages both the animation and events from the X server. 


--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 202.118.239.121]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:6.269毫秒