CgFx: Get program used by pass

Started by
0 comments, last by Dave Eberly 16 years, 10 months ago
Hi there, I'm using the Cg API 1.5 and Cg effect files for rendering. Now I need to get the fragment program used by a pass. How am I doing this? I can't find a function in the (damn) API documentation. So, my effect looks something like: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ float4 FP(float3 texCoord : TEXCOORD0) : COLOR { return float4(texCoord,1); } technique T1 { pass { VertexProgram = NULL; FragmentProgram = compile arbfp1 FP(); CullFaceEnable = false; } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ And I have a CGpass handle in my application. Now I need something that gives me a CGprogram handle for the fragment program. Any ideas? Cheers, Felix
Advertisement
Presumably, you used cgCreateEffectFromFile to load the FX file. Why would you not just call cgCreateProgramFromEffect? For example,

float4x4 WVPMatrix;sampler2D baseSampler = sampler_state{  MinFilter = LinearMipMapLinear;  MagFilter = Linear;};void VP(   float4 inPosition  : POSITION,   float2 inTCoord : TEXCOORD0,   out float4 outPosition : POSITION,   out float2 outTCoord : TEXCOORD0,   uniform float4x4 matrix){   outPosition  = mul(inPosition, matrix);   outTCoord = inTCoord;}void FP(   float2 inTCoord : TEXCOORD0,   out float4 pixelColor : COLOR,   uniform sampler2D sampler){    pixelColor = tex2D(sampler, inTCoord);}technique Technique1{   pass Pass1   {      VertexProgram = compile arbvp1 VP(WVPMatrix);      FragmentProgram = compile arbfp1 FP(baseSampler);   }}


In code,
    CGcontext context = cgCreateContext();    cgGLRegisterStates(context);    CGeffect effect = cgCreateEffectFromFile(context,"Test.fx",0);    CGtechnique technique = cgGetNamedTechnique(effect, "Technique1");    CGpass pass = cgGetNamedPass(technique, "Pass1");    CGprogram vprogram = cgCreateProgramFromEffect(effect,        cgGLGetLatestProfile(CG_GL_VERTEX),"VP",0);    CGprogram fprogram = cgCreateProgramFromEffect(effect,        cgGLGetLatestProfile(CG_GL_FRAGMENT),"FP",0);


Perhaps you could provide more details about why you think you need to access the program handle from the pass handle.

This topic is closed to new replies.

Advertisement