GLSL Vertex shader compile error

Started by
2 comments, last by ElectroDruid 15 years, 1 month ago
Hi, I'm new to GLSL, and I'm trying to get started by getting some of the clockwork coders tutorials to compile and run (the ones here: http://www.clockworkcoders.com/oglsl/tutorials.html ). Specifically, I've jumped in at Tutorial 10 - Simple Toon Shading. The code compiles and runs, but then the call to glGetObjectParameterivARB(ProgramObject, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); when trying to compile the vertex shader fails to set the compiled flag, and the compiler log reports the following errors:
Quote:***COMPILER ERROR (Vertex Shader): 0(12) : error C0000: syntax error, unexpected $undefined at token "<undefined>" 0(12) : error C0501: type name expected at token "<undefined>"
This is the vertex shader in question:
varying vec3 vNormal;
varying vec3 vVertex;


void main(void)
{
  vVertex = gl_Vertex.xyz;
  vNormal = gl_Normal;

  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}


I don't see how there can be anything wrong with the vertex shader itself, so could it be something wrong with my compiler or hardware setup? I'm using Visual Studio 2008, running Windows Vista on a Dell XPS M1530, with an NVidia GeForce 8600M GT graphics card - the operating system, BIOS and graphics card drivers are all completely up-to-date. What could be going wrong here?
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner
Advertisement
Are you reading the shader from a file or is it a hard coded string inside your C++ code? If you're reading it from a file, make sure you're reading it in correctly and not getting the non-character byte values, such as new line, tab, carriage return, ect...
Author Freeworld3Dhttp://www.freeworld3d.org
I believe I had this error when first reading my files. wound up adding

file[size-1]='\0';

to fix it..
That worked a treat, cherryyosh! The shader file I was loading in was completely fine (no unusual characters , but the ifstream which the tutorial uses to load the shader does weird stuff and seems to store a bunch of garbage at the end. The program tries to NULL terminate the broken string, but adds the terminator one character too late.
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner

This topic is closed to new replies.

Advertisement