load_shader.cpp 853 B

123456789101112131415161718192021222324252627
  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. #include "load_shader.h"
  9. // Copyright Denis Kovacs 4/10/08
  10. #include "print_shader_info_log.h"
  11. #include <cstdio>
  12. IGL_INLINE GLuint igl::opengl::load_shader(const char *src,const GLenum type)
  13. {
  14. GLuint s = glCreateShader(type);
  15. if(s == 0)
  16. {
  17. fprintf(stderr,"Error: load_shader() failed to create shader.\n");
  18. return 0;
  19. }
  20. // Pass shader source string
  21. glShaderSource(s, 1, &src, NULL);
  22. glCompileShader(s);
  23. // Print info log (if any)
  24. igl::opengl::print_shader_info_log(s);
  25. return s;
  26. }