Cg problems. Help

DarkCW

Newcomer
Hello, I'm new here.

I'm starting with Cg. I have made a couple of things with it and OpenGL.
Everyting ok until now. I was trying to run an example of the book "The Cg Tutorial", but I can't execute it properly.

The Cg program creates a Double Vision Effect using a Vertex and a Fragment Program. The VP and FP compile well (I'm using ARBVP1 & ARBFP1 profiles. My graphic card is an ATI Mobility Radeon 9700). But when I try to load the Vertex Program, the Cg compiler says me that "the program couldn't be loaded".

This is the code:



Code:
static void LoadCgPrograms(){

    assert(cgIsContext(context));

    // Cargamos y compilamos el VP
    vertexProgram = cgCreateProgramFromFile(context, CG_SOURCE, CWD "Shaders/DoubleVisionVP.cg",
                                            vertexProfile, NULL, NULL);

    if (!cgIsProgramCompiled(vertexProgram))
        cgCompileProgram(vertexProgram);

-------------------------------------------------------------------------------
    // Activamos el VP
    cgGLLoadProgram(vertexProgram); //Here is where it fails
    cgGLEnableProfile(vertexProfile); //Vertex Profile --> ARBVP1
--------------------------------------------------------------------------------

    // De igual forma tenemos que hacerlo para los FP
    fragmentProgram = cgCreateProgramFromFile(context, CG_SOURCE, CWD "Shaders/DoubleVisionFP.cg",
                                              fragmentProfile, NULL, NULL);
    if (!cgIsProgramCompiled(fragmentProgram))
        cgCompileProgram(fragmentProgram);


    cgGLLoadProgram(fragmentProgram);
	cgGLEnableProfile(fragmentProfile);
}

I don't know what is happening. I have used the ARBVP1 profile before whitout problems.

By the way, I tried to install CgFX Viewer yesterday, but I wasn't able to do it. Whe the installation began, an error appeared. It said something about the CgFXParser.dll. It seemed that I had the 0.0.1.5 version and I need a previous one (0.0.0.4 or something). Where I can find this?

Thanks ;)
 
Can't anyone help me?

By the way, I have written that same shader with the Fx composer, and it works perfectly.

This is the code of the shaders:

Code:
//Vertex program
void main(	float3 posicion : POSITION,
			float2 texCoord : TEXCOORD0,
			
			out float4 oPosition : POSITION,
			out float2 leftTexCoord : TEXCOORD0,
			out float2 rightTexCoord : TEXCOORD1,
			
			uniform float2 leftOffset,
			uniform float2 rightOffset){
			
	oPosition = float4(posicion, 1);
	leftTexCoord = texCoord + leftOffset;
	rightTexCoord = texCoord + rightOffset;
	
}

//Fragment program
void main(	float2 leftTexCoord : TEXCOORD0,
			float2 rightTexCoord: TEXCOORD1,
			
			out float4 color : COLOR,
			
			uniform sampler2D decal){
			
	float4 leftColor = tex2D(decal,leftTexCoord);
	float4 rightColor = tex2D(decal,rightTexCoord);
	color = lerp(leftColor, rightColor, 0.5);
	
}
 
Well, eventually I find the mistake. I had an error with one of the parameters in the Vertex program. The VP compiled well because the syntax was correct, but then...

I had put:

leftTexCoord = texCoord + leftTexCoord;

instead of:

leftTexCoord = texCoord + leftOffset;


:rolleyes: :rolleyes:
 
I guess this is a case of the "cardboard programmer" helping out again.
 
Back
Top