Hi Mael, David

One word of caution, there seem to be some issues with passing Uniform
arrays, from the messages on this list, you could hit some
implementations of GLSL where it will not work very well.

For me it worked on nvidia and an array of bools (I think I had about 8
elements).

First create the uniform, then the array for the values, and then set
the array. This is the init code, where no values are being set:

    osg::ref_ptr<osg::Uniform> newU = new
osg::Uniform(osg::Uniform::BOOL, m_nameTypeMap[LIGHTS_ARRAY].c_str(),
m_numLights);     
   osg::ref_ptr<osg::IntArray> arr = new osg::IntArray(m_lightsArray,
m_lightsArray + m_numLights);
< ... set values ? ... >
   newU->setArray(arr.get());

If it's about passing packed data in, you can also use a 4x4 float matrix.

Cheers
Mihai

David Callu wrote:
> Hi mael
>
>   never try but probably with osg::Uniform::setArray(FloatArray * array);
>
> David Callu
>
> 2007/9/11, Mael Blanchard <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>>:
>
>     Hi all,
>     I would like to put in my GLSL shader a uniform array variable,
>     I know how to put a simple float or int value with osg::Uniform,
>     but for an array I don't know
>     Is anyone can help me?
>
>     thanks
>
>     Mael.
>
>     _______________________________________________
>     osg-users mailing list
>     osg-users@lists.openscenegraph.org
>     <mailto:osg-users@lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>     
> <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to