print_shader_info_log.h 936 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef IGL_PRINT_SHADER_INFO_LOG_H
  2. #define IGL_PRINT_SHADER_INFO_LOG_H
  3. #ifdef __APPLE__
  4. # include <OpenGL/gl.h>
  5. #else
  6. # ifdef _WIN32
  7. # define NOMINMAX
  8. # include <Windows.h>
  9. # undef NOMINMAX
  10. # endif
  11. # include <GL/gl.h>
  12. #endif
  13. namespace igl
  14. {
  15. // Inputs:
  16. // obj OpenGL index of shader to print info log about
  17. inline void print_shader_info_log(const GLuint obj);
  18. }
  19. // Implementation
  20. #include <cstdio>
  21. // Copyright Denis Kovacs 4/10/08
  22. inline void igl::print_shader_info_log(const GLuint obj)
  23. {
  24. GLint infologLength = 0;
  25. GLint charsWritten = 0;
  26. char *infoLog;
  27. // Get shader info log from opengl
  28. glGetShaderiv(obj, GL_INFO_LOG_LENGTH,&infologLength);
  29. // Only print if there is something in the log
  30. if (infologLength > 0)
  31. {
  32. infoLog = (char *)malloc(infologLength);
  33. glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog);
  34. printf("%s\n",infoLog);
  35. free(infoLog);
  36. }
  37. }
  38. #endif