compile_shader.h 836 B

1234567891011121314151617181920212223242526
  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. IGL_INLINE GLuint compile_shader(const GLint type, const char * str);
  22. }
  23. #ifndef IGL_STATIC_LIBRARY
  24. # include "compile_shader.cpp"
  25. #endif
  26. #endif