sized array of float as parameter to nvidia cg shader

I am trying to use Cg shaders to blend textures within a fragment shader. I want to set weights for each image that i would like to pass down to the shader as a uniform variable of float arrays. These weights are fixed array of floats that would be reset variably. Is this possible? I see there is a method cgGLSetParameterArray1f(CGparameter, int offset, int nelements, float* values) and a method CgSetActiveSize(CGparameter param, int size).

Even though i use these methods i get errors while creating the shader using CgCreateProgram().

Is it possible to do what i am trying to achieve and can someone give me or point me to a sample code? even rough snippets of code or pointers would do.

If this is accomplishable in glsl, then I surmise that there must be something similar in cg as well…so please let me know how its done in glsl too so that i can search for its counterpart in cg too

thanks a lot…

Anyone? Am i in the right forum to post?

This really isn’t an OpenGL question. I’d direct you to The Cg Forum on NVidia’s developer website, …but I see it’s still down.

If you post on this site, the High-level APIs is probably the better spot.

At any rate, I don’t know the answer to your question. You might actually post the error message. Might give someone something to go on.

[QUOTE=Dark Photon;1243355]This really isn’t an OpenGL question. I’d direct you to The Cg Forum on NVidia’s developer website, …but I see it’s still down.

If you post on this site, the High-level APIs is probably the better spot.

At any rate, I don’t know the answer to your question. You might actually post the error message. Might give someone something to go on.[/QUOTE]

Thank you for the reply… yes unfortunately nvidia’s forums are down. I will post the error message as soon as possible and post it on the high level apis as well…thank you.

i figured out how to accomplish what i was seeking…Just in case someone else stumbled into this , heres what i did:

cg runtime actually allows you set a size the size of an array. So you would need to :

  • create an array using cgCreateParameterArray{fr}(…)
  • get the name of the parameter from the shader program using cgGetParameterName(…)
  • set the size of the unsized array variable using cgSetArraySize(…)
  • connect the created parameter to the parameter you just got with previous step, using cgConnectParameter(…)
  • re-compile the program and load using cgCompileProgram(…) and cgLoadProgram(…).

It is to be noted that most of the operations of resizing the array is done by the cg runtime, so as per the documentation, it is recommended to set the compilation mode in cg to manual using cgSetAutoCompile(…)