#ifndef CREATE_SHADER_PROGRAM_FROM_FILES_H #define CREATE_SHADER_PROGRAM_FROM_FILES_H #include #include // Create a GLSL shader program given a list of paths containing shader code for // each shader in the vertex-tessellation-fragment shader pipeline. Prints error // messages on failure. // // Inputs: // vertex_shader_paths ordered list of paths to files containing glsl vertex // shader code. // tess_control_shader_paths ordered list of paths to files containing glsl // tessellation control shader code. // tess_evaluation_shader_paths ordered list of paths to files containing glsl // tessellation evaluation shader code. // fragment_shader_paths ordered list of paths to files containing glsl fragment // shader code. // Outputs: // id identifier of compiled shader program // Returns true iff success inline bool create_shader_program_from_files( const std::vector & vertex_shader_paths, const std::vector & tess_control_shader_paths, const std::vector & tess_evaluation_shader_paths, const std::vector & fragment_shader_paths, GLuint & id); // Implementation #include #include #include "REDRUM.h" #include "STR.h" #include "print_shader_info_log.h" #include "print_program_info_log.h" inline bool create_shader_program_from_files( const std::vector & vertex_shader_paths, const std::vector & tess_control_shader_paths, const std::vector & tess_evaluation_shader_paths, const std::vector & fragment_shader_paths, GLuint & id) { const auto create_compile_attach = []( const std::vector & paths, const GLenum type, const GLuint prog_id, GLuint & s) -> bool { const std::string type_str = (type == GL_VERTEX_SHADER ? STR(BOLD("vertex shader")) : (type == GL_FRAGMENT_SHADER ? STR(BOLD("fragment shader")) : (type == GL_TESS_CONTROL_SHADER ? STR(BOLD("tessellation control shader")) : (type == GL_TESS_EVALUATION_SHADER ? STR(BOLD("tessellation evaluation shader")) : "unknown shader")))); int total_length = 0; std::vector strs; { for(int p = 0;p(buffer.str().length()); } } std::vector cstrs; for(const auto & str : strs) { cstrs.emplace_back(str.c_str()); } if(total_length == 0) { std::cerr<