So I got this:
CGpass pass = cgGetFirstPass(technique);
while(pass)
{
// for each mesh (2 cubes)
cgSetPassState(pass);
cgSetParameterMatrixfr(...);
cgUpdatePassParameters();
RenderTheMesh();
cgResetPassState(pass);
pass = cgGetNextPass();
}
Now according to the nvidia examples this should work. It doesn't. What happens is that I have two meshes, one in position (0,0,8) and one in position (0,5,0). Both meshes render at position (0,5,0). Cg seems to render both meshes at the second and last world position that is set (0,5,0).
However, if I use two different shaders for both the cubes, it does work properly. And, if I call cgSetPassState() for each mesh that I render within the same pass, it also works... but I don't want that because I'll be state-raping my videocard to hell, as I'll be setting 264 renderstates per call to cgSetPassState().
The parameter I'm setting is a global uniform parameter (uniform float4x4 g_world : WORLD). Passing the g_world to the vertex program as a scope variable also didn't yield any results (in uniform float4x4 in_world).
Does anyone know what I'm doing wrong?