Can I call a breakpoint for OpenGL errors in Xcode 4?

Is it possible to set a symbolic breakpoint that will fire when any call to the OpenGL function sets any state other than GL_NO_ERROR ? The initial data indicate that opengl_error_break designed to serve precisely this purpose, but it is not violated.

+6
source share
3 answers

Based on Lars's approach, you can automatically track errors based on some preprocessing magic and creating stub functions.

I wrote a small Python script that processes the OpenGL header (I used Mac OS X alone in the example, but it should also work with iOS).

The Python script generates two header files for inclusion in your project wherever you call OpenGL, like this (you can name the header you want):

 #include "gl_debug_overwrites.h" 

The header contains macros and function declarations after this scheme:

 #define glGenLists _gl_debug_error_glGenLists GLuint _gl_debug_error_glGenLists(GLsizei range); 

The script also creates the source file in the same stream, which you must save separately, compile and link to your project.

Then all gl* functions will be transferred to another function with the _gl_debug_error_ prefix, which then checks for errors like this:

 GLuint _gl_debug_error_glGenLists(GLsizei range) { GLuint var = glGenLists(range); CHECK_GL_ERROR(); return var; } 
+5
source

Wrap OpenGL calls to call glGetError after each call in debug mode. Inside the wrapper method, create a conditional breakpoint and verify that the return value of glGetError is different from GL_NO_ERROR .

More details:

Add this macro to your project (from the OolongEngine project):

#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s\n", __error, __FUNCTION__); (__error ? NO : YES); })

Find all your OpenGL calls manually or with the appropriate RegEx. Then you have two options shown for calling glViewport() :

  • Replace the call to glViewport(...); CHECK_GL_ERROR() glViewport(...); CHECK_GL_ERROR()
  • Replace the call to glDebugViewport(...); and implement glDebugViewport , as shown in (1).
+5
source

I think that because of the problem there may be a problem grab the OpenGL ES framework (scroll down to “Capture OpenGL ES Frames”), which is now supported by Xcode. At least that's how I debug my OpenGL games.

By capturing frames when you know that an error is occurring, you can identify the problem in the OpenGL stack without much effort.

Hope this helps!

+1
source

Source: https://habr.com/ru/post/903341/


All Articles