setting parameters for Cg Vertex program
Why does this code fragment not work?
float[] preRotatedQuad =
{
vPoint0.x, vPoint0.y, vPoint0.z, 0.0f,
vPoint1.x, vPoint1.y, vPoint1.z, 0.0f,
vPoint2.x, vPoint2.y, vPoint2.z, 0.0f,
vPoint3.x, vPoint3.y, vPoint3.z, 0.0f
};
IntPtr m_CGparam_preRotatedQuad = Cg.cgGetNamedParameter(m_CGprogram, "preRotatedQuad"); CgGl.cgGLSetParameterArray4f(m_CGparam_preRotatedQuad, 0, 4, preRotatedQuad);
It fails on last line with Access violaton exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
edit(cg program):
struct appin
{
float4 position : POSITION;
float4 color0 : COLOR0;
float4 texcoord0 : TEXCOORD0;
};
struct vertout
{
float4 position : POSITION;
float4 color0 : COLOR0;
float4 texcoord0 : TEXCOORD0;
};
vertout main( appin IN,
uniform float4x4 modelViewProj,
uniform float4 size,
uniform float4 preRotatedQuad[4] )
{
vertout OUT;
// Build-up a float4 position from a float3 position and then transform it.
float4 vCenter = float4( IN.position.x, IN.position.y, IN.position.z, 1.0f );
OUT.position = mul( modelViewProj, vCenter + preRotatedQuad[IN.texcoord0.z] * IN.texcoord0.w );
IN.texcoord0.z = 0.0f; // Remove the hidden information from the z component
IN.texcoord0.w = 1.0f; // Remove the hidden information from the w component
OUT.color0 = IN.color0;
OUT.texcoord0 = IN.texcoord0;
return OUT;
}

can somebody please tell me
can somebody please tell me how to properly pass array parameter into Cg programs?