load_shader.cpp 520 B

12345678910111213141516171819202122
  1. #include "load_shader.h"
  2. #ifndef IGL_NO_OPENGL
  3. // Copyright Denis Kovacs 4/10/08
  4. #include "print_shader_info_log.h"
  5. #include <cstdio>
  6. IGL_INLINE GLuint igl::load_shader(const char *src,const GLenum type)
  7. {
  8. GLuint s = glCreateShader(type);
  9. if(s == 0)
  10. {
  11. fprintf(stderr,"Error: load_shader() failed to create shader.\n");
  12. return 0;
  13. }
  14. // Pass shader source string
  15. glShaderSource(s, 1, &src, NULL);
  16. glCompileShader(s);
  17. // Print info log (if any)
  18. igl::print_shader_info_log(s);
  19. return s;
  20. }
  21. #endif