OpenGL ES Error to String
Asked Answered
E

2

6

Is there a standard for getting an error string from glGetError() (Android and iOS) and eglGetError() (Android) in OpenGL ES 1.1 or 2.0?

I'm using something like this:

#define AssertGL(x) { x; GLenum __gle = glGetError(); Assert(__gle == GL_NO_ERROR); }

Would be nice to enhance this to provide text to the debugger rather than having to look up the GLenum manually of the returned value stored in __gle.

Edda answered 19/8, 2013 at 17:10 Comment(0)
T
3

Try this on Android: http://developer.android.com/reference/android/opengl/GLU.html#gluErrorString(int) and this on iOS: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/gluErrorString.3.html

If those don't work for you, you can always create your own mapping from the integer error value to a corresponding string - it should be easy since there's only a handful of error values. Just look up the error values from the gl2.h and gl.h headers (they start with 0x05).

Tonietonight answered 25/8, 2013 at 15:17 Comment(3)
I don't think there's anything similar to GLU library for EGL afaik, you'll probably have to do that manually anyway. But again, there's only a few errors to handle.Tonietonight
I suppose so. And yeah, I have to do Android manually too, because gluGetError() isn't exposed. I did end up finding this though: code.google.com/p/gluesEdda
Note that iOS link is broken.Overexert
Y
4

Just follow the specs, GL is cross-platform:

char const* gl_error_string(GLenum const err) noexcept
{
  switch (err)
  {
    // opengl 2 errors (8)
    case GL_NO_ERROR:
      return "GL_NO_ERROR";

    case GL_INVALID_ENUM:
      return "GL_INVALID_ENUM";

    case GL_INVALID_VALUE:
      return "GL_INVALID_VALUE";

    case GL_INVALID_OPERATION:
      return "GL_INVALID_OPERATION";

    case GL_STACK_OVERFLOW:
      return "GL_STACK_OVERFLOW";

    case GL_STACK_UNDERFLOW:
      return "GL_STACK_UNDERFLOW";

    case GL_OUT_OF_MEMORY:
      return "GL_OUT_OF_MEMORY";

    case GL_TABLE_TOO_LARGE:
      return "GL_TABLE_TOO_LARGE";

    // opengl 3 errors (1)
    case GL_INVALID_FRAMEBUFFER_OPERATION:
      return "GL_INVALID_FRAMEBUFFER_OPERATION";

    // gles 2, 3 and gl 4 error are handled by the switch above
    default:
      assert(!"unknown error");
      return nullptr;
  }
}
Yurikoyursa answered 23/8, 2017 at 3:8 Comment(0)
T
3

Try this on Android: http://developer.android.com/reference/android/opengl/GLU.html#gluErrorString(int) and this on iOS: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/gluErrorString.3.html

If those don't work for you, you can always create your own mapping from the integer error value to a corresponding string - it should be easy since there's only a handful of error values. Just look up the error values from the gl2.h and gl.h headers (they start with 0x05).

Tonietonight answered 25/8, 2013 at 15:17 Comment(3)
I don't think there's anything similar to GLU library for EGL afaik, you'll probably have to do that manually anyway. But again, there's only a few errors to handle.Tonietonight
I suppose so. And yeah, I have to do Android manually too, because gluGetError() isn't exposed. I did end up finding this though: code.google.com/p/gluesEdda
Note that iOS link is broken.Overexert

© 2022 - 2024 — McMap. All rights reserved.