compile_shader.h 897 B

12345678910111213141516171819202122232425262728
  1. #ifndef IGL_COMPILE_SHADER_H
  2. #define IGL_COMPILE_SHADER_H
  3. #include "OpenGL_convenience.h"
  4. #include "igl_inline.h"
  5. namespace igl
  6. {
  7. // Compile a shader given type and string of shader code
  8. //
  9. // Inputs:
  10. // type either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
  11. // str contents of shader code
  12. // Returns result of glCreateShader (id of shader)
  13. //
  14. // Example:
  15. // GLuint vid = compile_shader(GL_VERTEX_SHADER,vertex_shader.c_str());
  16. // GLuint fid = compile_shader(GL_FRAGMENT_SHADER,fragment_shader.c_str());
  17. // GLuint prog_id = glCreateProgram();
  18. // glAttachShader(prog_id,vid);
  19. // glAttachShader(prog_id,fid);
  20. // glLinkProgram(prog_id);
  21. //
  22. // Known bugs: seems to be duplicate of `load_shader`
  23. IGL_INLINE GLuint compile_shader(const GLint type, const char * str);
  24. }
  25. #ifndef IGL_STATIC_LIBRARY
  26. # include "compile_shader.cpp"
  27. #endif
  28. #endif