Yes, the shader code posted is the exact code that is loaded in the file and compiled. There are no comments so it can't be that unfortunately. My test XP machine has a 7800GTS and my Vista machine has an 8800GTX, so if anyone who has a similar machine and driver could test this shader then it'd be really useful.
I've decided to post the code that loads the shader as well in case there is a problem with it.
std::fstream filestream; char *vsdata, *psdata; int filelength; CXMLFile shaderfile(filename); std::string error; int compileresult = 0; int infologLength = 0; int charsWritten = 0; char *infoLog; unsigned int uniformloc; //Initialize internal variables this->shadername = filename; if(shaderfile.IsOpen()) { this->vsname = shaderfile.GetValue("/shader/vertex"); this->psname = shaderfile.GetValue("/shader/pixel"); } this->id = 0; this->loaded = false; //Attempt to load vertex shader data filestream.open(this->vsname.data(), std::ios::in); if(filestream.is_open()) { //Load in our data filestream.seekg(0, std::ios_base::end); filelength = filestream.tellg(); filestream.seekg(0, std::ios_base::beg); vsdata = new char[filelength+1]; memset(vsdata, 0, filelength+1); filestream.read(vsdata, filelength); filestream.close(); } else { //Log which file cannot be opened error = "CShader::CShader - Vertex shader '"; error += this->vsname; error += "' from the shader file '"; error += this->shadername; error += "' could not be loaded"; g_cLog.WriteError(ERROR_WARNING, error); return; } //Load the pixel shader filestream.open(this->psname.data(), std::ios::in); if(filestream.is_open()) { //Load in our data filestream.seekg(0, std::ios_base::end); filelength = filestream.tellg(); filestream.seekg(0, std::ios_base::beg); psdata = new char[filelength+1]; memset(psdata, 0, filelength+1); filestream.read(psdata, filelength); filestream.close(); } else { //Log which file cannot be opened error = "CShader::CShader - Pixel shader '"; error += this->psname; error += "' from the shader file '"; error += this->shadername; error += "' could not be loaded"; g_cLog.WriteError(ERROR_WARNING, error); return; } //Submit to OpenGL and link them this->vsid = glCreateShader(GL_VERTEX_SHADER); glShaderSourceARB(this->vsid, 1, (const char**)&vsdata,NULL); glCompileShaderARB(this->vsid); glGetShaderiv(this->vsid, GL_COMPILE_STATUS, &compileresult); if (compileresult != GL_TRUE) { error = "CShader::CShader - GLSL compilation of '"; error += this->shadername; error += "' failed."; g_cLog.WriteError(ERROR_WARNING, error); glGetShaderiv(this->vsid, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { infoLog = new char[infologLength]; glGetInfoLogARB(this->vsid, infologLength, &charsWritten, infoLog); g_cLog.WriteError(ERROR_WARNING, infoLog); delete[] infoLog; } return; } this->psid = glCreateShader(GL_FRAGMENT_SHADER); glShaderSourceARB(this->psid, 1, (const char**)&psdata,NULL); glCompileShaderARB(this->psid); glGetShaderiv(this->psid, GL_COMPILE_STATUS, &compileresult); if (compileresult != GL_TRUE) { error = "CShader::CShader - GLSL compilation of '"; error += this->shadername; error += "' failed."; g_cLog.WriteError(ERROR_WARNING, error); glGetShaderiv(this->psid, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { infoLog = new char[infologLength]; glGetInfoLogARB(this->psid, infologLength, &charsWritten, infoLog); g_cLog.WriteError(ERROR_WARNING, infoLog); delete[] infoLog; } return; } this->id = glCreateProgram(); glAttachShader(this->id,this->vsid); glAttachShader(this->id,this->psid); glLinkProgram(this->id); //Check it linked ok glGetProgramiv(this->id, GL_LINK_STATUS, &compileresult); if (compileresult != GL_TRUE) { error = "CShader::CShader - GLSL compilation of '"; error += this->shadername; error += "' failed."; g_cLog.WriteError(ERROR_WARNING, error); glGetShaderiv(this->id, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { infoLog = new char[infologLength]; glGetInfoLogARB(this->id, infologLength, &charsWritten, infoLog); g_cLog.WriteError(ERROR_WARNING, infoLog); delete[] infoLog; } return; } //Free our resources if(vsdata) delete[] vsdata; if(psdata) delete[] psdata;
If anyone can spot an error then I'd be much appreciated. I've spent all day today trying to fix this bug and I'm stuck. Thanks again.