What is the best way to debug OpenGL?

前端 未结 10 1613
半阙折子戏
半阙折子戏 2020-12-12 17:51

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 ma

相关标签:
10条回答
  • 2020-12-12 18:21

    There is also the free glslDevil: http://www.vis.uni-stuttgart.de/glsldevil/

    It allows you to debug glsl shaders extensively. It also shows failed OpenGL calls.

    However it's missing features to inspect textures and off screen buffers.

    0 讨论(0)
  • 2020-12-12 18:25

    Apitrace is a relatively new tool from some folks at Valve, but It works great! Give it a try: https://github.com/apitrace/apitrace

    0 讨论(0)
  • 2020-12-12 18:27

    I found you can check using glGetError after every line of code your suspect will be wrong, but after do it, the code looks not very clean but it works.

    0 讨论(0)
  • 2020-12-12 18:29

    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.

    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.

    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.

    0 讨论(0)
  • 2020-12-12 18:29

    GLIntercept is your best bet. From their web page:

    • Save all OpenGL function calls to text or XML format with the option to log individual frames.
    • Free camera. Fly around the geometry sent to the graphics card and enable/disable wireframe/backface-culling/view frustum render
    • Save and track display lists. Saving of the OpenGL frame buffer (color/depth/stencil) pre and post render calls. The ability to save the "diff" of pre and post images is also available.
    0 讨论(0)
  • 2020-12-12 18:30

    The gDebugger is an excellent free tool, but no longer supported. However, AMD has picked up its development, and this debugger is now known as CodeXL. It is available both as a standalone application or as a Visual Studio plugin - works both for native C++ applications, or Java/Python applications using OpenGL bindings, both on NVidia and AMD GPUs. It's one hell of a tool.

    0 讨论(0)
提交回复
热议问题