compile_shader.h 1.2 KB

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