I find this annoying but is there a better way to retrieve a struct parameter from a Cg shader?
In the 11_two_light_with_structs example (OpenGL), there's a struct Material in the shader:
Cg shader:
// From page 128
struct Material {
float3 Ke;
float3 Ka;
float3 Kd;
float3 Ks;
float shininess;
};
Then in the code they do this:
C code:
myCgVertexParam_material_Ke = cgGetNamedParameter( myCgVertexProgram, "material.Ke" );
myCgVertexParam_material_Ka = cgGetNamedParameter( myCgVertexProgram, "material.Ka");
myCgVertexParam_material_Kd = cgGetNamedParameter( myCgVertexProgram, "material.Kd");
myCgVertexParam_material_Ks = cgGetNamedParameter( myCgVertexProgram, "material.Ks");
Seems tedious, can't you just do
myCgVertexParam_materialALL = cgGetNamedParameter( myCgVertexProgram, "material" ) ;
Then something like:
cgSetParameterValuefr( myCgVertexParam_materialALL, 13, brassMat ) ;//! no.
Here I'm trying to treat the struct as an array, but that last command doesn't work though, with the error "The parameter is not of a numeric type."