I checked with one of the examples, as far as I can tell I do everything identical, but the problem is still the same (that example works though).
So, I guess the problem doesn't lie in the shader then. Here are the parts of my main.cpp that are relevant:
CGcontext context;CGprogram program;CGprofile profile;CGparameter ambientColorParameter;void cgErrorCallback(){ CGerror error = cgGetError ( ); if ( error != CG_NO_ERROR ) { printf ( "%s\n", cgGetErrorString ( error ) ); done = true; }}void init_shader ( CGprogram program, const char* filename ){ cgSetErrorCallback(cgErrorCallback); context = cgCreateContext ( ); profile = cgGLGetLatestProfile ( CG_GL_FRAGMENT ); cgGLSetOptimalOptions ( profile ); program = cgCreateProgramFromFile ( context, CG_SOURCE, filename, profile, NULL, NULL ); cgGLLoadProgram ( program ); cgGLBindProgram ( program ); cgGLEnableProfile ( profile );}void init ( void )// initializes the game{ // initialize window window.create ( WINDOW_TITLE, "settings.cfg" ); // initialize textures texture[0].init ( "texture1.bmp", FILTER_LINEAR ); texture[1].init ( "texture2.bmp", FILTER_LINEAR ); // do other unrelated stuff... // init shader init_shader ( program, "lighting.cg" ); // get parameter (tried to do every frame in draw() as well, didn't check nothing ambientColorParameter = cgGetNamedParameter ( program, "test" );}void draw ( void )// draws everything{ cgGLBindProgram ( program ); cgGLEnableProfile ( profile ); // OpenGL lighting must be disabled since the pixel shader // program will compute the lighting value glDisable ( GL_LIGHTING ); // Set the (fixed) ambient color value cgGLSetParameter3f ( ambientColorParameter, 0.4f, 0.4f, 0.4f ); // The first texture unit contains the detail texture glActiveTextureARB ( GL_TEXTURE0_ARB ); glEnable ( GL_TEXTURE_2D ); glBindTexture ( GL_TEXTURE_2D, texture[0].id ); glRotatef ( rotate, 0.0f, 1.0f, 0.0f ); glBegin ( GL_TRIANGLES ); for ( int i = 0; i < 2; i++ ) { for ( int j = 0; j < 3; j++ ) { cvector normalized_lvector; light_vector.set ( triangle.vertex[j], light_position ); normalized_lvector = light_vector; normalize ( normalized_lvector ); // Bind the light vector to COLOR0 and interpolate // it across the edge glColor4f ( normalized_lvector.x, normalized_lvector.y, normalized_lvector.z, length ( light_vector ) ); // Bind the texture coordinates to TEXTURE0 and // interpolate them across the edge glMultiTexCoord2fARB(GL_TEXTURE0_ARB, triangle.vertex[j].u, triangle.vertex[j].v); // Specify the vertex coordinates glVertex3f(triangle.vertex[j].x, triangle.vertex[j].y, triangle.vertex[j].z); } } glEnd ( ); cgGLDisableProfile ( profile );}
That's all identical to the example-code, if I didn't miss anything (the example code is really somewhat unreadable).