load_shader.cpp 866 B

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