report_gl_error.h 755 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #include <string>
  12. namespace igl
  13. {
  14. // Print last OpenGL error to stderr prefixed by specified id string
  15. // Inputs:
  16. // id string to appear before any error msgs
  17. // Returns result of glGetError()
  18. inline GLenum report_gl_error(const std::string id = string(""));
  19. }
  20. // Implementation
  21. #include "verbose.h"
  22. inline GLenum igl::report_gl_error(const std::string id)
  23. {
  24. GLenum err = glGetError();
  25. if(GL_NO_ERROR != err)
  26. {
  27. verbose("GL_ERROR: ");
  28. fprintf(stderr,"%s%s\n",id.c_str(),gluErrorString(err));
  29. }
  30. return err;
  31. }
  32. #endif