How would use DrawElementsUShort to assign the individual vertex attributes?
Some examples I found online used TemplateIndexArray, which is why I went that
route.
Thanks.
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Robert Osfield
Sent: Wed 6/27/2007 2:00 PM
To: osg users
Subject: Re: [osg-users] Shaders Question
Hi Bryan,
As a general guide never use array indices with osg::Geometry as it
forces the OSG down onto OpenGL slow paths - OpenGL itself simply
doesn't support deferences on indices separately for each vertex
arrays.
The way to do indexing is use DrawElementsUShort() instead of
DrawArrays. This may require repeating some values but it far more
efficient for OpenGL to handle.
I don't know why you code segment gives examples of using
TemplateIndexArray, this is just confusing alround, the typesefs in
include/osg/Array for FloatArray, Vec2Array etc are much much more
readable.
On 6/27/07, Wasileski, Bryan J. <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> The question below is being forwarded from "Larry"...
>
> I was wondering if someone could explain how setVertexAttribIndices
> works. In my application, I have an array of vertices that I set for my
> geometry. I then build my triangle primitives using those vertices (when
> I build my triangles, some vertices are used more than once). If I want
> to assign an attribute variable to be accessed by my shaders, do I have
> to assign it twice for the vertices that are repeated or just once? If
> not, is the indexArray that I am passing into setVertexAttribIndices
> array just a 1:1 mapping with the indices of my vertex array? Currently,
> when I have my attribute array the same size as my vertices, I get a
> segmentation fault. Here is the code I am using:
>
>
>
> TemplateIndexArray <unsigned int, Array::UIntArrayType, 1,
> GL_UNSIGNED_INT> *index;
> index = new TemplateIndexArray<unsigned int, Array::UIntArrayType, 1,
> GL_UNSIGNED_INT>;
>
> for (int i = 0; i < itsVertices->size(); i++)
> {
> index->push_back(i); // vertex 0 assigned color array element
> }
>
> TemplateArray <GLfloat, Array::FloatArrayType, 1, GL_FLOAT>*
> thePatchAttributes = new TemplateArray <GLfloat, Array::FloatArrayType,
> 1, GL_FLOAT>;
>
> for (int i = 0; i < itsVertices->size(); i++)
> {
> thePatchAttributes->push_back(info[0] + info[1]);
> }
> itsGeometry->setVertexAttribArray (6, thePatchAttributes);
> itsGeometry->setVertexAttribIndices(6, index);
> itsGeometry->setVertexAttribBinding (6, osg::Geometry::BIND_PER_VERTEX);
>
> Thanks.
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/