调试 OpenGL 的最佳方法是什么? [英] What is the best way to debug OpenGL?

查看:37
本文介绍了调试 OpenGL 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现很多时候,OpenGL 会通过不绘制任何内容来向您展示它失败了.我试图通过检查转换矩阵堆栈等来找到调试 OpenGL 程序的方法.调试 OpenGL 的最佳方法是什么?如果代码看起来和感觉上顶点都在正确的位置,您如何确定它们是正确的?

I find that a lot of the time, OpenGL will show you it failed by not drawing anything. I'm trying to find ways to debug OpenGL programs, by inspecting the transformation matrix stack and so on. What is the best way to debug OpenGL? If the code looks and feels like the vertices are in the right place, how can you be sure they are?

推荐答案

没有直接的答案.这一切都取决于你试图理解什么.由于 OpenGL 是一个状态机,有时它不会执行您期望的操作,因为未设置所需的状态或类似的事情.

There is no straight answer. It all depends on what you are trying to understand. Since OpenGL is a state machine, sometimes it does not do what you expect as the required state is not set or things like that.

通常,使用 glTrace/glIntercept(查看 OpenGL 调用跟踪)、gDebugger(可视化纹理、着色器、OGL 状态等)和纸/铅笔等工具:).有时,了解您如何设置相机以及它的位置、正在剪辑的内容等会有所帮助.与前两种方法相比,我个人更依赖于最后一种方法.但是当我可以争辩说深度是错误的时,那么查看轨迹会有所帮助.gDebugger 也是唯一可有效用于分析和优化 OpenGL 应用的工具.

In general, use tools like glTrace / glIntercept (to look at the OpenGL call trace), gDebugger (to visualize textures, shaders, OGL state etc.) and paper/pencil :). Sometimes it helps to understand how you have setup the camera and where it is looking, what is being clipped etc. I have personally relied more to the last than the previous two approaches. But when I can argue that the depth is wrong then it helps to look at the trace. gDebugger is also the only tool that can be used effectively for profiling and optimization of your OpenGL app.

除了这个工具之外,大多数时候人们出错的是数学,使用任何工具都无法理解.在 OpenGL.org 新闻组上发表特定于代码的评论,您永远不会失望.

Apart from this tool, most of the time it is the math that people get wrong and it can't be understood using any tool. Post on the OpenGL.org newsgroup for code specific comments, you will be never disappointed.

这篇关于调试 OpenGL 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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