   NVidia CG: Global Struct parameter
  Hello everybody.i'm using NVidia CG toolkit version 1.5 beta 2, and i have the following problem:I have a struct in my cg shader like:struct SLight{ float4 pos; float4 dir;};and i also have a global instance of this struct :SLight gLight;-I whant to do two things:1. share this instance over several cg program.2. i also whant to set this unfiform data by passing an equivalent struct from my dx program.in a first time, i try to use context shared parameters, but if i use this , it seam that the cgD3D9SetUniform() function do not work ( i get an unknow error ) even with the cg Version 1.5 ...So, i cannot set this data directly with a struct ... ( and that's pretty boring if my struct contain a large amount of data )If i do not use Shared parameters, the cgD3D9SetUniform() work, but i'm not sure that my instance will be shared over several program .... Can you help me ?does Global data in a cg shader are shared over several programs ??Do you know any other function which can set a whole struct as parameter ??Thanks a lot Clement Vidal   
  Hello,I can't help you with the sharing part, but I do know how do pass structures to your cg programs. You have to construct a loop and initialize each structure like this.(this is code for OpenGL, but Direct3D should have similar Cg functions)CGParameter SLight[MAX_NUMBER_OF_LIGHTS];for(int i = 0; i <= NUM_OF_LIGHTS; i++){   char position[255] = {0};   char direction[255] = {0};   sprintf(position, "light[%d].pos", i);   sprintf(direction, "light[%d].dir", i);   cgGetNamedParameter(YOUR_CG_PROGRAM, position);   cgGetNamedParameter(YOUR_CG_PROGRAM, direction);}Then you've got to set the structures initial values like this:for(int i = 0; i <= NUM_OF_LIGHTS; i++){   cgGLSetParameter4fv(light.pos, YOUR_LIGHT_POSITION);   cgGLSetParameter4fv(light.dir, YOUR_LIGHT_DIRECTION);}Now, your cg programs can accept these parameters like this:struct SLight{float4 pos;float4 dir;};void main(uniform SLight light[MAX_NUMBER_OF_LIGHTS]){}Hope this was enough to get you started. This code might not be the most effecient, it is understandible and can easily be optimized to your liking.Hope I have been helpful,Jeroen