// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "create_shader_program.h" #include "load_shader.h" #include "print_program_info_log.h" #include #include IGL_INLINE bool igl::opengl::create_shader_program( const std::string & geom_source, const std::string & vert_source, const std::string & frag_source, const std::map & attrib, GLuint & id) { using namespace std; if(vert_source == "" && frag_source == "") { cerr<< "create_shader_program() could not create shader program," " both .vert and .frag source given were empty"<::const_iterator ait = attrib.begin(); ait != attrib.end(); ait++) { glBindAttribLocation( id, (*ait).second, (*ait).first.c_str()); } // Link program glLinkProgram(id); const auto & detach = [&id](const GLuint shader) { if(shader) { glDetachShader(id,shader); glDeleteShader(shader); } }; detach(g); detach(f); detach(v); // print log if any igl::opengl::print_program_info_log(id); return true; } IGL_INLINE bool igl::opengl::create_shader_program( const std::string & vert_source, const std::string & frag_source, const std::map & attrib, GLuint & prog_id) { return create_shader_program("",vert_source,frag_source,attrib,prog_id); } IGL_INLINE GLuint igl::opengl::create_shader_program( const std::string & geom_source, const std::string & vert_source, const std::string & frag_source, const std::map & attrib) { GLuint prog_id = 0; create_shader_program(geom_source,vert_source,frag_source,attrib,prog_id); return prog_id; } IGL_INLINE GLuint igl::opengl::create_shader_program( const std::string & vert_source, const std::string & frag_source, const std::map & attrib) { GLuint prog_id = 0; create_shader_program(vert_source,frag_source,attrib,prog_id); return prog_id; } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation #endif