GLuint loadShaderG(char * vertPath, char * fragPath, char * geoPath, std::vector<const char*> layoutLocations) { Logger()<< "Creating Shader" << std::endl; Logger() <<"Vertex: " << vertPath << std::endl; GLuint vertID = glCreateShader(GL_VERTEX_SHADER); loadShaderPart(vertID, vertPath); Logger() <<"Fragment: "<< fragPath << std::endl; GLuint fragID = glCreateShader(GL_FRAGMENT_SHADER); loadShaderPart(fragID, fragPath); Logger() <<"Geometry: "<< geoPath << std::endl; GLuint geoID = glCreateShader(GL_GEOMETRY_SHADER); loadShaderPart(geoID, geoPath); GLuint programID = glCreateProgram(); glAttachShader(programID, vertID); glAttachShader(programID, fragID); glAttachShader(programID, geoID); createProgram(programID, layoutLocations); glDeleteShader(vertID); glDeleteShader(fragID); glDeleteShader(geoID); return programID; }
GLuint loadShader(const char* vertexFile, const char* fragmentFile) { GLuint vert, frag, program; if (oglError() != GL_NO_ERROR) /* just in case an error occurred beforehand */ printf("NOTE: GL error set before call to loadShader()\n"); /* load vertex and fragment shaders */ vert = loadShaderPart(vertexFile, GL_VERTEX_SHADER); frag = loadShaderPart(fragmentFile, GL_FRAGMENT_SHADER); if (!vert && !frag) return 0; /* create the shader program object */ program = glCreateProgram(); /* attach the shader objects to the program */ if (vert) glAttachShader(program, vert); if (frag) glAttachShader(program, frag); /* link the attached shader objects to create the shader executable */ glLinkProgram(program); /* check for errors */ programError(program); /* now it's compiled we don't need the intermediates */ if (vert) glDeleteShader(vert); if (frag) glDeleteShader(frag); /* return our shader program */ oglError(); return program; }