create_shader_program.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef IGL_CREATE_SHADER_PROGRAM_H
  2. #define IGL_CREATE_SHADER_PROGRAM_H
  3. #ifndef IGL_NO_OPENGL
  4. #include "igl_inline.h"
  5. #include <string>
  6. #include <map>
  7. #include "OpenGL_convenience.h"
  8. namespace igl
  9. {
  10. // Create a shader program with a vertex and fragments shader loading from
  11. // source strings and vertex attributes assigned from a map before linking the
  12. // shaders to the program, making it ready to use with glUseProgram(id)
  13. // Inputs:
  14. // vert_source string containing source code of vertex shader
  15. // frag_source string containing source code of fragment shader
  16. // attrib map containing table of vertex attribute strings add their
  17. // correspondingly ids (generated previously using glBindAttribLocation)
  18. // Outputs:
  19. // id index id of created shader, set to 0 on error
  20. // Returns true on success, false on error
  21. //
  22. // Note: Caller is responsible for making sure that current value of id is not
  23. // leaking a shader (since it will be overwritten)
  24. //
  25. // See also: destroy_shader_program
  26. IGL_INLINE bool create_shader_program(
  27. const std::string vert_source,
  28. const std::string frag_source,
  29. const std::map<std::string,GLuint> attrib,
  30. GLuint & id);
  31. }
  32. #ifdef IGL_HEADER_ONLY
  33. # include "create_shader_program.cpp"
  34. #endif
  35. #endif
  36. #endif