Aumnayan

08-16-2012, 02:34 PM

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\n",

(GLchar*) "uniform sampler2D vertTexture; \n",

(GLchar*) "uniform sampler2D normTexture; \n",

(GLchar*) "uniform vec3 sunpos; \n",

(GLchar*) "uniform vec4 transMatrix; \n",

(GLchar*) "in vec2 vPosition; \n",

(GLchar*) "out float color; \n",

(GLchar*) "out float diff; \n",

(GLchar*) "void main () { \n",

(GLchar*) " vec2 tpos = vec2(vPosition.xy); \n",

(GLchar*) " tpos.x = (tpos.x * transMatrix.b) + transMatrix.r; \n",

(GLchar*) " tpos.y = (tpos.y * transMatrix.a) + transMatrix.g; \n",

(GLchar*) " vec4 vert = texture(vertTexture, tpos); \n",

(GLchar*) " vec3 norm = texture(normTexture, tpos).xyz; \n",

(GLchar*) " color = clamp(((vert.y / 1.5f) + 400.0f) / 5120.0f, 0.02f, 1.0f); \n",

(GLchar*) " diff = clamp(dot(norm.xyz, normalize(sunpos - vert.xyz)), 0.6f, 1.0f); \n",

(GLchar*) " gl_Position = gl_ModelViewProjectionMatrix * vert; \n",

(GLchar*) "}"

};

GLchar *TerrainFragmentShaderStr[] = {

(GLchar*) "#version 120\n",

(GLchar*) "uniform sampler1D colorTexture; \n",

(GLchar*) "uniform sampler2D grndTexture; \n",

(GLchar*) "in float color; \n",

(GLchar*) "in float diff; \n",

(GLchar*) "void main () { \n",

(GLchar*) " vec4 vcolor = texture1D(colorTexture, color); \n",

//" vec4 tcolor = texture(grndTexture, texCrd); \n",

(GLchar*) " gl_FragColor = vcolor * diff; \n",

(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.

My current shaders:

GLchar *TerrainVertexShaderStr[] = {

(GLchar*) "#version 120\n",

(GLchar*) "uniform sampler2D vertTexture; \n",

(GLchar*) "uniform sampler2D normTexture; \n",

(GLchar*) "uniform vec3 sunpos; \n",

(GLchar*) "uniform vec4 transMatrix; \n",

(GLchar*) "in vec2 vPosition; \n",

(GLchar*) "out float color; \n",

(GLchar*) "out float diff; \n",

(GLchar*) "void main () { \n",

(GLchar*) " vec2 tpos = vec2(vPosition.xy); \n",

(GLchar*) " tpos.x = (tpos.x * transMatrix.b) + transMatrix.r; \n",

(GLchar*) " tpos.y = (tpos.y * transMatrix.a) + transMatrix.g; \n",

(GLchar*) " vec4 vert = texture(vertTexture, tpos); \n",

(GLchar*) " vec3 norm = texture(normTexture, tpos).xyz; \n",

(GLchar*) " color = clamp(((vert.y / 1.5f) + 400.0f) / 5120.0f, 0.02f, 1.0f); \n",

(GLchar*) " diff = clamp(dot(norm.xyz, normalize(sunpos - vert.xyz)), 0.6f, 1.0f); \n",

(GLchar*) " gl_Position = gl_ModelViewProjectionMatrix * vert; \n",

(GLchar*) "}"

};

GLchar *TerrainFragmentShaderStr[] = {

(GLchar*) "#version 120\n",

(GLchar*) "uniform sampler1D colorTexture; \n",

(GLchar*) "uniform sampler2D grndTexture; \n",

(GLchar*) "in float color; \n",

(GLchar*) "in float diff; \n",

(GLchar*) "void main () { \n",

(GLchar*) " vec4 vcolor = texture1D(colorTexture, color); \n",

//" vec4 tcolor = texture(grndTexture, texCrd); \n",

(GLchar*) " gl_FragColor = vcolor * diff; \n",

(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.