GLSL: strange syntax error?

Started by
4 comments, last by Terrimus 14 years, 4 months ago
Hi I am getting some strange (and random) errors when trying to use a shader.
Fragment info
-------------
0(14) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(14) : error C0501: type name expected at token "<undefined>"
This is a simple shader just taking the color from the the first texture Vertex:
void main() {
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = ftransform();
}
Fragment:
uniform sampler2D Texture0;
uniform sampler2D Texture1;

void main() {
    vec4 tex0, tex1;
    
    tex0 = texture2D(Texture0, gl_TexCoord[0].st);
    tex1 = texture2D(Texture1, gl_TexCoord[0].st);
		
    gl_FragColor = tex1;
}
I've run this code some times, and sometimes I get the error, sometimes I don't. But I can't see any syntax errors? I set the TextureX-variables like this:
glUniform1i(glGetUniformLocation(programID, "Texture0"), tex0);
[Edited by - Terrimus on November 26, 2009 11:20:05 AM]
Advertisement
I apparently fixed it.

Just added
if(!GLEW_ARB_multitexture || (glActiveTexture == NULL) || (glClientActiveTexture == NULL)) {    	cout << "Warning! No multitexture support!" << endl;    }


in my glew-initiating method, and now it works. :O
*bump*

new strange syntax error :S (see top)
glUniform1i(glGetUniformLocation(programID, "Texture0"), tex0);

Your shader doesn't use Texture0 so it might get optimized away. But it was a while since I last did GLSL so I'm not 100% sure.
Hm, maybe there is a issue with my graphic card driver?

Seems like glGetUniformLocation allways return -1.
Think I've solved it.

I changed my shader-class to properly detach and delete the shaders/program, and now it seems to work.

So if anyone else have the same problem try that :P

This topic is closed to new replies.

Advertisement