Sign in to follow this  
long_xz

how to use glProgramLocalParameter

Recommended Posts

this is my CG program: // flat.cg uniform float4 flatScale : flatScale; uniform float4 dmapScale : dmapScale; float isFlat(float3 a, float3 b, float3 c, float3 d, float disp, float dscale2) { float3 v1, v2; float distance; distance = flatScale.x * (b.z + c.z + dscale2); if (distance < flatScale.y) distance = flatScale.z - distance; distance -= disp; v1 = a + c - 2*b; v2 = b + d - 2*c; return (float) (dot(v1, v1) + dot(v2, v2) < distance*abs(distance)); } float2 cvt(float index) { float2 result; result.y = index; result.x = frac(index)*1024; return result; } float4 main(float4 offsetCoord : TEX0, float4 dstCoord : WPOS, float4 epCoord : TEX1, uniform samplerRECT srcTexMap : TEXUNIT0, uniform samplerRECT epTexMap : TEXUNIT1, uniform samplerRECT offsetTexMap : TEXUNIT2) : COL { float4 s0, s2, s3, s4, s5, s7, s10; float4 srcCoords = dstCoord.xyxy + texRECT(offsetTexMap, offsetCoord.xy); float2 srcCoord = srcCoords.xy; s0 = texRECT(srcTexMap, srcCoord + float2(0, -1)); s2 = texRECT(srcTexMap, srcCoord + float2(-1, 0)); s3 = texRECT(srcTexMap, srcCoord); s4 = texRECT(srcTexMap, srcCoord + float2(1, 0)); s5 = texRECT(srcTexMap, srcCoord + float2(2, 0)); s7 = texRECT(srcTexMap, srcCoord + float2(0, 1)); s10 = texRECT(srcTexMap, srcCoord + float2(0, 2)); if (s0.w > 1) s0 = texRECT(epTexMap, cvt(s0.w)+epCoord.xy); if (s10.w > 1) s10 = texRECT(epTexMap, cvt(s10.w)+epCoord.xy); if (s2.w > 1) s2 = texRECT(epTexMap, cvt(s2.w)+epCoord.xy); if (s5.w > 1) s5 = texRECT(epTexMap, cvt(s5.w)+epCoord.xy); return float2(isFlat(s2.xyz, s3.xyz, s4.xyz, s5.xyz, d.x, d2), isFlat(s0.xyz, s3.xyz, s7.xyz, s10.xyz, d.w, d2)).xyxy; } how to use glProgramLocalParameter to set the parameters "flatScale" and "dmapScale" in my c++ program? or is there any other way to set the parameters? my CG progrma is not use Dynamic loading,i complie it in a .bat file

Share this post


Link to post
Share on other sites
I think you must use 'cgSetParameter*()' though I have not worked on CG. For this, you need to pass a 'CGparameter' which you may get by using either getParameterByName() or getParameterBySemantic(). Since you re using high level shader, this (using named parameters instead of register numbers) looks ideal.

Regards,
KumGame07

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this