About GLSL shader compile error

I used cgc 2.0 to compile glsl vertex shader,and return the down information:
multiTex.glslv(25) : error C7506: OpenGL does not define the global function dot
multiTex.glslv(25) : error C7506: OpenGL does not define the global function max

I dont know why the error occured.
help!!!
My code as down:

 
#version 120
varying vec3 normal;
varying vec3 V;
uniform vec4 ambientDiffuse;
uniform vec4 lightDiffuse;

void main()
{
    vec4 texCoord[]={gl_MultiTexCoord0,gl_MultiTexCoord1,
                     gl_MultiTexCoord2,gl_MultiTexCoord3,
                     gl_MultiTexCoord4,gl_MultiTexCoord5,
                     gl_MultiTexCoord6,gl_MultiTexCoord7};
 
    gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;
    
    for(int i=0;i<gl_MaxTextureCoords;i++)
    {
        gl_TexCoord[i]=texCoord[i];
    }

    normal=normalize(gl_NormalMatrix*gl_Normal);
    
    V=normalize((gl_ModelViewMatrix*gl_Vertex-gl_LightSource[0].position).xyz);
    
    gl_FrontColor=max(dot(normal,V),0.0)*ambientDiffuse*lightDiffuse;
}

and I set the *.bat file like this:

cgc -profile glslv -entry main -oglsl -o asm.txt -l cInfo.txt multiTex.glslv

cgc is a Cg tool.
According to this :
http://lists.apple.com/archives/Mac-opengl/2007/Feb/msg00068.html
it is not very robust.

You may try GLSL Validate :
http://developer.3dlabs.com/downloads/glslvalidate/index.htm

Thanks ,but cgc 2.0 supported leave context(background) compiler for GLSL.I used it compile many GLSL shader and all passed through before I reinstalled system.

are u parsing it correctly?

also nvidia cards (not sure about the nv80)
only allow 32varying floats

gl_TexCoord[i]=texCoord[i]; equals 4 floats
(4*8 texture units = 32 + then add the normal + V + youll run into the message max varyings exceeded)

Varying floats?Not problem with it.See the compiler error:

multiTex.glslv(25) : error C7506: OpenGL does not define the global function dot
multiTex.glslv(25) : error C7506: OpenGL does not define the global function max

cgc -profile glslv -entry main -oglsl -o asm.txt -l cInfo.txt multiTex.glslv
Why are you compiling a GLSL source to a GLSL profile?
I would have expected arbvp1, vp30, or vp40 as profile.

And you should really not use your texCoord array this way.
It would break if gl_MaxTexCoords > 8 because you hardcoded eight MultiTexCoord into the array. Just assign them manually, that’s the simplest way to get it right.
And when compiling this to an assembly profile you will see that you will run out of varyings with eight gl_TexCoords plus two vec3 varyings.

“also nvidia cards (not sure about the nv80)
only allow 32varying floats”

G80 reports a whopping 60.

It not passed through also after I changed the number of gl_MultiTexCoord form 8 to 4 and return the same error that:the function “dot” and “max” not defined in GL

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