load_shader.cpp 491 B

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