create_shader_program.h 1.4 KB

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