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