   glLinkProgram() returning false
  I don't think I quite understand how to load shaders from a file because when I query GL_LINK_STATUS after attempting to link my program, it is false.Here is the code I'm using to load a shader from file.  I left out the part where I actually create the program, bind attributes and link it.    std::ifstream vertexShaderFile;    vertexShaderFile.open("shader_0.vert");    if (!vertexShaderFile) {   return(false);    }    std::string line;    std::stringstream stream;    while (!vertexShaderFile.eof()) {   std::getline(vertexShaderFile, line);   stream << line << "\n";    }    vertexShaderFile.close();    const char* vertexShaderSource = stream.str().c_str();    vertexShaderID = glCreateShader(GL_VERTEX_SHADER);    glShaderSource(vertexShaderID, 1, &vertexShaderSource, 0);    glCompileShader(vertexShaderID);And here is my vertex shader -- this could be wrong for all I know, I'm a complete noob to shaders.#version 130uniform mat4 projectionMatrix;uniform mat4 modelviewMatrix;in vec4 in_vertex;void main() {    gl_Position = projectionMatrix * modelviewMatrix * in_vertex;}Thanks.[Edited by - X Abstract X on April 13, 2010 1:16:33 AM]
  If querying GL_LINK_STATUS gives you false, then you can download the program log to find out what is wrong. It will give you a plaintext string much like a regular compiler that should tell you what is the problem.glGetProgramiv(prog,GL_LINK_STATUS,&result);if(result == GL_TRUE){ ...} else {  int maxLength;  int length;  glGetProgramiv(prog,GL_INFO_LOG_LENGTH,&maxLength);  char* log = new char[maxLength];  glGetProgramInfoLog(prog,maxLength,&length,log);}During development it might be a good idea to check GL_INFO_LOG_LENGTH even if link status is true. It can contain warning messages that may be of interest to you. Just check if length is greater than 1, and download the result if so.   ;Quote:Original post by karwostsIf querying GL_LINK_STATUS gives you false, then you can download the program log to find out what is wrong. It will give you a plaintext string much like a regular compiler that should tell you what is the problem.*** Source Snippet Removed ***During development it might be a good idea to check GL_INFO_LOG_LENGTH even if link status is true. It can contain warning messages that may be of interest to you. Just check if length is greater than 1, and download the result if so.Alright cool, thanks for the advice.  The log reported for each of my shaders @ line 1:syntax error, $undefined token "<undefined>"type name expected at token "<undefined>"Now this error seems pretty generic to me, a google search yielded a bunch of different reasons for the error.  I'm going to start trying some ideas.  Thanks.;  Are you sure your shaders are compiling properly before you try to link them? You can get info logs for each shader in a similar command with glGetShaderiv and glGetShaderInfoLog instead of glGetProgramiv/glGetProgramInfoLog. glGetProgram* is only for after you attach both shaders and run glLinkProgram. I would expect 90% of errors to be found during shader compiling rather than linking, and if you try to link a shader that fails to compile that might explain your cryptic program message.Its not clear from the code you posted, but you need to:glCreateShader  //vertex shaderglShaderSourceglCompileShader(check Shader Error Log)glCreateShader  //fragment shaderglShaderSourceglCompileShader(check Shader Error Log)glCreateProgramglAttachShader  //Vertex ShaderglAttachShader  //Fragment ShaderglLinkProgram(check Linker Error Log - this was the step I gave you in my first post);  Thanks again for posting.  Yes, I'm doing everything you said.  In fact, I know the problem now but I'm unsure of how to fix it.  By doing a bit of debugging I was able to determine that the source of the error is definitely in my file I/O code.  By using a C-style file reading technique the errors I had before were fixed but I've got an error on the final line on each shader now -- probably something to do with null terminating C-style strings, I have to look into that right now.   ;  do you have an empty line at the end of file? I had a problem and i solved it with just clicking ENTER key at the end and saving.   