Shaders Failed to link on new computer

Started by
6 comments, last by Seabolt 10 years, 6 months ago

Hey guys, I'm hoping someone here has experience with this:

I recently got a new computer. I've moved over all my code, and when I try to run, my shaders fail to link. They work on my previous computer. I've installed the latest nVidia drivers, and I successfully create my shader context. But It says that I'm not writing to gl_Position when I know I am.

Any ideas?

Perception is when one imagination clashes with another
Advertisement

Probably some small error in your code that your old driver was tolerating, but your new driver is being strict about mellow.png

Post the code and errors?

The error I got was

Failed to Link VS_RenderFlatNoTex, errors:
Vertex info
-----------
(0) : error C5145: must write to gl_Position
The shader code is


uniform mat4	g_mWorldViewProjection;


attribute vec3	Input_Position;
attribute vec4	Input_Color0;

varying vec4	IO_Color0;

void M44xV3(mat4 Matrix_In, vec3 Vector_In, out vec4 Result)
{
        Result=(Matrix_In * vec4(Vector_In, 1.0));
}

void main()
{
	vec4 M44xV3_4_Result;
	M44xV3(g_mWorldViewProjection, Input_Position, M44xV3_4_Result);
					
					
	gl_Position = M44xV3_4_Result;
	IO_Color0 = Input_Color0;
}

(Note the code is a bit shortened. Sorry for the strange functions for multiplying, the shaders are generated.)

Also this linker error is happening to all of my shaders, not just this one.

Perception is when one imagination clashes with another

Interesting, now it's saying it can't find void main()... I'm looking at the string of code I send it, and it definitely is there...

Perception is when one imagination clashes with another

I think I solved it, for some reason glShaderSource wasn't accepting the '0' length for the shader code. According to the spec that means that the array will be NULL terminated, and that it would use the length of the string as the code length. But if I just use a simple strlen on the code and pass that size it works... That's a bit worrying.

Now I get to figure out why nothing is drawing anymore, and why there are no errors because of it! Yipee!

Perception is when one imagination clashes with another

my guess is you're reading out of a file which would not have a NULL terminator

I think I solved it, for some reason glShaderSource wasn't accepting the '0' length for the shader code. According to the spec that means that the array will be NULL terminated, and that it would use the length of the string as the code length. But if I just use a simple strlen on the code and pass that size it works... That's a bit worrying.

Now I get to figure out why nothing is drawing anymore, and why there are no errors because of it! Yipee!

The specification says that the string is assumed to be null terminated if the length is less than zero. Strictly according to the specification, a length of zero actually means a zero-length string. You have to use a negative value to indicate an individually null-terminated string in the length vector.

Huh that's interesting. I was previously using zero as my length and it was working.

I suppose either way one driver or another was messing it up.

Perception is when one imagination clashes with another

This topic is closed to new replies.

Advertisement