OpenGL Programming/Debugging

MesaEdit

If you are using the Mesa OpenGL implementation you can set the following environment variables:

  • LIBGL_ALWAYS_SOFTWARE=1 : use the software implementation, without using the graphic card at all. This help when:
    • you suspect a bug in a driver,
    • you want to try an alternative implementation (as if you were using a different graphic card),
    • you want to check whether a graphic glitch is due to unitialized memory or to a programming mistake
  • MESA_DEBUG=1 : will output diagnostic messages in erroneous situations (e.g. assigning a uniform when the program is not linked)

See also Mesa's debugging and environment variables pages.

Common mistakesEdit

If you manually draw lines or triangles, and nothing appears:

  • check that your 4th coordinate is 1 and not 0
  • check that you properly set glEnableVertexAttribArray / glBindBuffer / glVertexAttribPointer
  • double-check that you used the right variables (bad copy/paste...) - avoid global variables to help this
  • triple-check your glUniform* calls, including the type (3fv, 4fv...) - OpenGL is unforgiving and silent
  • beware that glDrawElements' 4th and last parameter (indices) is expressed in byte offset from the start, not in number of elements from the start, even when working with IBOs

Stencil bufferEdit

For tips on how to debug the stencil buffer, you can check the Stencil buffer section.

LinksEdit

< OpenGL Programming

Browse & download complete code
Last modified on 19 May 2013, at 10:20