compile_shader.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_OPENGL_COMPILE_SHADER_H
  9. #define IGL_OPENGL_COMPILE_SHADER_H
  10. #include "OpenGL_convenience.h"
  11. #include "../igl_inline.h"
  12. namespace igl
  13. {
  14. namespace opengl
  15. {
  16. // Compile a shader given type and string of shader code
  17. //
  18. // Inputs:
  19. // type either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
  20. // str contents of shader code
  21. // Returns result of glCreateShader (id of shader)
  22. //
  23. // Example:
  24. // GLuint vid = compile_shader(GL_VERTEX_SHADER,vertex_shader.c_str());
  25. // GLuint fid = compile_shader(GL_FRAGMENT_SHADER,fragment_shader.c_str());
  26. // GLuint prog_id = glCreateProgram();
  27. // glAttachShader(prog_id,vid);
  28. // glAttachShader(prog_id,fid);
  29. // glLinkProgram(prog_id);
  30. //
  31. // Known bugs: seems to be duplicate of `load_shader`
  32. IGL_INLINE GLuint compile_shader(const GLint type, const char * str);
  33. }
  34. }
  35. #ifndef IGL_STATIC_LIBRARY
  36. # include "compile_shader.cpp"
  37. #endif
  38. #endif