print_shader_info_log.h 847 B

12345678910111213141516171819202122232425262728293031323334353637
  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. # include <GL/gl.h>
  7. #endif
  8. namespace igl
  9. {
  10. // Inputs:
  11. // obj OpenGL index of shader to print info log about
  12. inline void print_shader_info_log(const GLuint obj);
  13. }
  14. // Implmentation
  15. #include <cstdio>
  16. // Copyright Denis Kovacs 4/10/08
  17. inline void igl::print_shader_info_log(const GLuint obj)
  18. {
  19. GLint infologLength = 0;
  20. GLint charsWritten = 0;
  21. char *infoLog;
  22. // Get shader info log from opengl
  23. glGetShaderiv(obj, GL_INFO_LOG_LENGTH,&infologLength);
  24. // Only print if there is something in the log
  25. if (infologLength > 0)
  26. {
  27. infoLog = (char *)malloc(infologLength);
  28. glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog);
  29. printf("%s\n",infoLog);
  30. free(infoLog);
  31. }
  32. }
  33. #endif