Jump to content
  • Advertisement
Sign in to follow this  
data2

CgFx: Get program used by pass

This topic is 3998 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!