Compile error points to a bracket

Hi, I’m trying to write a shader to perform a water/ocean reflection effect. I’m in Win32 using dev-cpp with glut. I keep running into a problem that i have previously run into while trying to write shaders. It seems like maybe I have run out of instructions or something, The compiler error i get is this:

Fragment info

(15) : error C0000: syntax error, unexpected ‘)’ at token “)”
(15) : error C0501: type name expected at token “)”

But the 15th line of the program is simply the closing bracket ( ‘}’ ) of my main function. And theres nothing after it. My fragment shader looks like this:

varying vec4 eVec;
uniform float texseed;
uniform sampler2D normMap1, normMap2;
uniform samplerCube cubeMap;

void main( )
	float dp;
	vec4 nVec1 = texture2D( normMap1, gl_TexCoord[ 0 ].st ) * 2.0 - 1.0;
	vec4 nVec2 = texture2D( normMap2, gl_TexCoord[ 0 ].st ) * 2.0 - 1.0;
	vec4 nVec = mix( nVec1, nVec2, texseed );
	dp = clamp( dot( normalize( eVec ), nVec ) * 2.0 + 1.0, 0.0, 1.0 );
	gl_FragColor = mix( vec4( 0.0, 0.3, 0.35, 1.0 ), textureCube( cubeMap, vec3( reflect( eVec, nVec ) ) ), dp );

if anyone counted, at 15, you end up at }. So anyway, to remove the error i deleted the clamp at line 13. So one might think clamp is giving me a problem, but i replaced ‘vec4 nVec = mix( nVec1, nVec2, texseed );’ with
‘vec4 nVec = nVec1;’ and put the clamp back in, and it once again compiled fine. If i am really using too many instructions it seems like there aren’t enough…


Compiles fine for me after adding a vertex shader which calculates eVec.
Make sure you do not have any non-printable invalid characters in the string.

ok so this is weird. I made a new file and opened it in wordpad instead of notepad this time. Then i typed in the shader (didn’t copy and paste) as it was and compiled and it worked. Then i made another file, opened it in notepad, copied and pasted the code, and it didn’t work. Made another file, opened in wordpad, copied and pasted the code, and it didn’t work again. Weeiird. Thanks for the help though.

Ah, even weirder. It doesn’t have to do with notepad/wordpad. I took out the tab indentations in front of each line and it compiles.

then i tried to add a ‘min’ funtion on an already existing line and it failed to compile. Maybe my drivers are to blame?

hmm, turns out, reading in the file was being done incorrectly. For some reason, changing the ifstream to binary made it work correctly.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.