I’m having a bit of a problem linking my shaders. They seam to build fine, but the vertex shader continually fails to link, without indicating what’s causing the link to fail. I’ve included source for a simple app which builds and links the shaders, which I am using to test at the moment, since I can’t seam to get to the point where I’m evaluating what the shaders are doing to the screen. Any ideas?
My current shaders:
GLchar TerrainVertexShaderStr[] = {
(GLchar) "#version 120
",
(GLchar*) "uniform sampler2D vertTexture;
",
(GLchar*) "uniform sampler2D normTexture;
",
(GLchar*) "uniform vec3 sunpos;
",
(GLchar*) "uniform vec4 transMatrix;
",
(GLchar*) "in vec2 vPosition;
",
(GLchar*) "out float color;
",
(GLchar*) "out float diff;
",
(GLchar*) "void main () {
",
(GLchar*) " vec2 tpos = vec2(vPosition.xy);
",
(GLchar*) " tpos.x = (tpos.x * transMatrix.b) + transMatrix.r;
",
(GLchar*) " tpos.y = (tpos.y * transMatrix.a) + transMatrix.g;
",
(GLchar*) " vec4 vert = texture(vertTexture, tpos);
",
(GLchar*) " vec3 norm = texture(normTexture, tpos).xyz;
",
(GLchar*) " color = clamp(((vert.y / 1.5f) + 400.0f) / 5120.0f, 0.02f, 1.0f);
",
(GLchar*) " diff = clamp(dot(norm.xyz, normalize(sunpos - vert.xyz)), 0.6f, 1.0f);
",
(GLchar*) " gl_Position = gl_ModelViewProjectionMatrix * vert;
",
(GLchar*) “}”
};
GLchar TerrainFragmentShaderStr[] = {
(GLchar) "#version 120
",
(GLchar*) "uniform sampler1D colorTexture;
",
(GLchar*) "uniform sampler2D grndTexture;
",
(GLchar*) "in float color;
",
(GLchar*) "in float diff;
",
(GLchar*) "void main () {
",
(GLchar*) " vec4 vcolor = texture1D(colorTexture, color);
“,
//” vec4 tcolor = texture(grndTexture, texCrd);
",
(GLchar*) " gl_FragColor = vcolor * diff;
",
(GLchar*) “}”
};
The output from my execution:
OpenGL Version: 2.1.8543 Release
GLSL Version: 1.20
Compiling vertex shader:
Vertex shader was successfully compiled to run on hardware.
Compiling fragment shader:
Fragment shader was successfully compiled to run on hardware.
Creating progrem:
Fragment shader(s) linked, vertex shader(s) failed to link.