Defines

CC3OpenGLES11Intercept.h File Reference

#include <OpenGLES/ES1/gl.h>

Defines

#define GL_LOGGING_ENABLED   0

Detailed Description


Define Documentation

#define GL_LOGGING_ENABLED   0

This file adds the ability to intercept all OpenGL ES 1.1 gl* calls in order to log the call to stdout, using printf, before actually making the call into the OpenGL ES 1.1 library.

The result is a log trace of all gl* calls, including the parameters used in each call.

Include this file at the top of any files that perform OopenGLES calls, or in a header file that is subsequently included wherever GL calls are made.

To be generically usable, this code is written in straight C. When including this header in C++ (.cpp) or Objective-C++ (.mm) files, wrap the include statement in an extern "C" declaration, as follows:

extern "C" { include "CC3OpenGLES11Intercept.h" }

This wrapping is NOT necessary when including this header in Objective-C (.m) files.

To enable logging all GL calls in any code that includes this file, set the compiler switch GL_LOGGING_ENABLED to 1. This can be set either in code, or as a compiler runtime parameter. Using a compiler runtime parameter is preferred.

The call-intercepting behaviour is implemented by re-defining each gl* function to an alias that generates the log entry before calling the original gl* function. With the GL_LOGGING_ENABLED set to 0, this aliasing and redirecting is completely skipped by the compiler. As a result, there is no runtime penalty incurred by this code when GL_LOGGING_ENABLED is set to 0. You can safely leave this file included in your header files at all times, even when building production code, provided the GL_LOGGING_ENABLED switch is not set to 1.

Logging all OpenGL libraries obviously incurs significant runtime overhead. You should only set the GL_LOGGING_ENABLED switch to 1 when you specifically need to log OpenGL calls. The default value of this switch is 0, so GL logging is turned off by default.

Use the compiler runtime parameter kPrintGLDataVertexCount to control how many elements of the data should be logged when data is passed to GL calls as data pointers (eg. glVertexPointer, glColorPointer, etc). The default value is 8.

Since many of the GL pointer data functions accept offsets for the pointer when used with data that has been bound, the compiler parameter kMinGLPointerAddress sets the minimum value for a pointer to be considered an address rather than an offset. For pointer values below this level, no attempt is made to extract data at that address. The default value is 8192.

Use the compiler parameter kPrintGLDataBufferDataCount to control how many elements of the data should be logged when data is passed as buffer data (eg. glBufferData). The default value is 64.