Sign in to follow this  
ElectroDruid

GLSL Vertex shader compile error

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this