Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: sized array of float as parameter to nvidia cg shader

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    9

    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..

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    9
    Anyone? Am i in the right forum to post?

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,224
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    9
    Quote Originally Posted by Dark Photon View 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.
    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.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    9
    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(...)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •