Graphics 版 (精华区)

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

4 Debugging Tips

As well as demonstrating the use of widgets with OpenGL, paperplane also demonstrates detection of OpenGL errors for
debugging purposes. Some debugging code has been added to the bottom of paperplane's draw function to test for any
OpenGL errors. A correct OpenGL program should not generate any OpenGL errors, but while debugging it is helpful to
check explicitly for errors. A good time to check for errors is at the end of each frame. Errors in OpenGL are not reported
unless you explicitly check for them, unlike X protocol errors which are always reported to the client. 

OpenGL errors are recorded by setting ``sticky'' flags. Once an error flag is set, it will not be cleared until glGetError is used
to query the error. An OpenGL implementation may have several error flags internally that can be set (since OpenGL errors
might occur in different stages of the OpenGL rendering pipeline). When you look for errors, you should call glGetError
repeatedly until it returns GL_NO_ERROR indicating that all of the error flags have been cleared. 

The OpenGL error model is suited for high performance rendering, since error reporting does not slow down the error-free
case. Because OpenGL errors should not be generated by bug-free code, you probably want to remove error querying from
your final program since querying errors will slow down your rendering speed. 

When an OpenGL error is generated, the command which generated the error is not recorded, so you may need to add more
error queries into your code to isolate the source of the error. 

The gluErrorString routine in the OpenGL Utility library (GLU) converts an OpenGL error number into a human readable
string and helps you output a reasonable error message. 

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