Next | Prev | Up | Top | Contents | Index

Creating a Trace File to Discover OpenGL Problems

A trace file helps you find bugs in the OpenGL portion of your code without having to worry about the mechanics of window operations. Here's an example of how to collect one frame of OpenGL calls:

  1. Launch ogldebug:

    % ogldebug your_program_name

  2. Click the Break (API calls) checkbox to select it, then click the Setup button next to it.

  3. In the Break Selection panel that appears, select a call that will result in a break after each frame: Either glXSwapBuffers() or glFlush(), depending on your program.

  4. Click the Trace (API calls) checkbox to record the sequence of OpenGL calls.

  5. Click the Continue button.

    Execution continues until just before the call(s) selected in the Break Selection panel--see Step 3. The ogldebug tool captures one frame worth of OpenGL calls, embeds them into the X shell window sample program, and saves them under the name program.trace.

  6. From a shell window, in your source directory, compile the shell:

    % mv program_name.trace trace.c

    % cc trace.c -lGL -lX11

  7. Launch the new a.out program to play back one frame of your application.
You can use dbx on the trace.c program to track down problems with your OpenGL code without having to deal with the rest of your application.

Note: In the trace file, all GLX calls are commented out with #ifdef to prevent them from being compiled unless the ALLOW_GLX_CALLS preprocessor constant is defined. This is because the GLX calls rely on values determined during execution of your application. On the next execution, these values are completely different; they're only provided as reference points, so you can determine where GLX calls were made.


Next | Prev | Up | Top | Contents | Index