Class GLDebug

All Implemented Interfaces:

public class GLDebug extends Object implements InvocationHandler
This class uses Reflection to intercept method calls to the Proxy Object (createProxy(GL, Object, Class[]) and extends them with the Error Checking in checkError().
This means we don't have to generate a class with overrides for every possible method just to add a checkError() call.
Note that we should not call checkError() for GL.glGetError(), it doesn't make sense.
Note that this class is general purpose and as such every class instance (every object) can be guarded as long as the passed gl instance is valid.
  • Field Details

    • obj

      protected Object obj
    • gl

      protected GL gl
    • methodGlGetError

      protected Method methodGlGetError
  • Method Details

    • decodeError

      protected String decodeError(int err)
    • checkError

      protected void checkError()
    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Specified by:
      invoke in interface InvocationHandler
    • createProxy

      public static Object createProxy(GL gl, Object obj, Class<?>... implementedInterfaces)
      Creates a debug-proxied object, which will call GL.glGetError() after every method invocation and throw a RendererException if there was a GL Error.
      gl - The GL Context, required to call GL.glGetError()
      obj - The object which methods will be proxied
      implementedInterfaces - The interfaces/class this object implements
      The Proxy object (or null if an error occurred)