// Same as above but for not-separated build GLuint GSShaderOGL::CompileShader(const std::string& glsl_file, const std::string& entry, GLenum type, const char* glsl_h_code, const std::string& macro_sel) { ASSERT(glsl_h_code != NULL); GLuint shader = 0; // Note it is better to separate header and source file to have the good line number // in the glsl compiler report const int shader_nb = 3; const char* sources[shader_nb]; std::string header = GenGlslHeader(entry, type, macro_sel); sources[0] = header.c_str(); sources[1] = common_header_glsl; sources[2] = glsl_h_code; shader = glCreateShader(type); glShaderSource(shader, shader_nb, sources, NULL); glCompileShader(shader); bool status = ValidateShader(shader); if (!status) { // print extra info fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), shader); fprintf(stderr, "\n%s", macro_sel.c_str()); fprintf(stderr, "\n"); } m_shad_to_delete.push_back(shader); return shader; }
GLuint GSShaderOGL::Compile(const std::string& glsl_file, const std::string& entry, GLenum type, const char* glsl_h_code, const std::string& macro_sel) { ASSERT(glsl_h_code != NULL); GLuint program = 0; #ifndef ENABLE_GLES if (type == GL_GEOMETRY_SHADER && !GLLoader::found_geometry_shader) { return program; } #endif // Note it is better to separate header and source file to have the good line number // in the glsl compiler report const char* sources[2]; std::string header = GenGlslHeader(entry, type, macro_sel); int shader_nb = 1; #if 1 sources[0] = header.c_str(); sources[1] = glsl_h_code; shader_nb++; #else sources[0] = header.append(glsl_h_code).c_str(); #endif if (GLLoader::found_GL_ARB_separate_shader_objects) { #ifndef ENABLE_GLES program = gl_CreateShaderProgramv(type, shader_nb, sources); #endif } else { program = gl_CreateShader(type); gl_ShaderSource(program, shader_nb, sources, NULL); gl_CompileShader(program); } bool status; if (GLLoader::found_GL_ARB_separate_shader_objects) status = ValidateProgram(program); else status = ValidateShader(program); if (!status) { // print extra info fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), program); fprintf(stderr, "\n%s", macro_sel.c_str()); fprintf(stderr, "\n"); } return program; }