create_shader_program.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_CREATE_SHADER_PROGRAM_H
  9. #define IGL_CREATE_SHADER_PROGRAM_H
  10. #ifndef IGL_NO_OPENGL
  11. #include "igl_inline.h"
  12. #include <string>
  13. #include <map>
  14. #include "OpenGL_convenience.h"
  15. namespace igl
  16. {
  17. // Create a shader program with a vertex and fragments shader loading from
  18. // source strings and vertex attributes assigned from a map before linking the
  19. // shaders to the program, making it ready to use with glUseProgram(id)
  20. // Inputs:
  21. // vert_source string containing source code of vertex shader
  22. // frag_source string containing source code of fragment shader
  23. // attrib map containing table of vertex attribute strings add their
  24. // correspondingly ids (generated previously using glBindAttribLocation)
  25. // Outputs:
  26. // id index id of created shader, set to 0 on error
  27. // Returns true on success, false on error
  28. //
  29. // Note: Caller is responsible for making sure that current value of id is not
  30. // leaking a shader (since it will be overwritten)
  31. //
  32. // See also: destroy_shader_program
  33. IGL_INLINE bool create_shader_program(
  34. const std::string &vert_source,
  35. const std::string &frag_source,
  36. const std::map<std::string,GLuint> &attrib,
  37. GLuint & id);
  38. IGL_INLINE GLuint create_shader_program(
  39. const std::string & vert_source,
  40. const std::string & frag_source,
  41. const std::map<std::string,GLuint> &attrib);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "create_shader_program.cpp"
  45. #endif
  46. #endif
  47. #endif