I'm trying to step into using shaders with OpenGL, but it seems I can't compile the shader. More frustratingly, it also appears the error log is empty. I've searched through this site extensively and checked many different tutorials but there doesn't seem to be an explanation for why it fails. I even bought a book dealing with shaders but it doesn't account for vanishing log files.
My feeling is that there must be an error with how I am linking the shader source.
//Create shader GLuint vertObject; vertObject = glCreateShader(GL_VERTEX_SHADER); //Stream ifstream vertfile; //Try for open - vertex try { //Open vertfile.open(vertex.c_str()); if(!vertfile) { // file couldn't be opened cout << "Open " << vertex << " failed."; } else { getline(vertfile, verttext, '\0'); //Test file read worked cout << verttext; } //Close vertfile.close(); } catch(std::ifstream::failure e) { cout << "Failed to open" << vertfile; } //Link source GLint const shader_length = verttext.size(); GLchar const *shader_source = verttext.c_str(); glShaderSource(vertObject, 1, &shader_source, &shader_length); //Compile glCompileShader(vertObject); //Check for compilation result GLint isCompiled = 0; glGetShaderiv(vertObject, GL_COMPILE_STATUS, &isCompiled); if (!isCompiled) { //Did not compile, why? std::cout << "The shader could not be compiled\n" << std::endl; char errorlog[500] = {'\0'}; glGetShaderInfoLog(vertObject, 500, 0, errorlog); string failed(errorlog); printf("Log size is %d", failed.size()); } printf("Compiled state = %d", isCompiled); The shader code is as trivial as can be.
void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } I can't get either my fragment or my vertex shader to compile. If I can get the error log to show, then at least I will be able to start error checking my own work. For now, though, I can't even get the errors.