report_gl_error.h 574 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef IGL_REPORT_GL_ERROR
  2. #define IGL_REPORT_GL_ERROR
  3. #ifdef __APPLE__
  4. # include <OpenGL/gl.h>
  5. # include <OpenGL/glu.h>
  6. #else
  7. # include <GL/gl.h>
  8. # include <GL/glu.h>
  9. #endif
  10. #include <cstdio>
  11. namespace igl
  12. {
  13. // Print last OpenGL error to stderr
  14. // Returns result of glGetError()
  15. inline GLenum report_gl_error();
  16. }
  17. // Implementation
  18. #include "verbose.h"
  19. inline GLenum igl::report_gl_error()
  20. {
  21. GLenum err = glGetError();
  22. if(GL_NO_ERROR != err)
  23. {
  24. verbose("GL_ERROR: ");
  25. fprintf(stderr,"%s\n",gluErrorString(err));
  26. }
  27. return err;
  28. }
  29. #endif