[osg-users] About Interleaved Array Support
Julien Valentin
julienvalentin51 at gmail.com
Wed Oct 10 04:34:16 PDT 2018
AFAIK Memory alignement compliance yield in greater performance..No?
robertosfield wrote:
> Hi Julien,
>
> I considered interleaved support in the past and decided against it as
> the value it provided isn't that great and it limits how many classes
> can process the geometry as it's an non standard form.
>
> Modern graphics card cope just fine with non interleaved data so what
> is your motivation?
>
> Cheers,
> Robert.
> On Wed, 10 Oct 2018 at 10:50, Julien Valentin
> <> wrote:
>
> >
> > Hi,
> > I have an implementation of InterleavedGeometry : public Drawable
> > I think it's really something missing for a long time in osg
> > Would it worse a pr...?
> >
> > here's a sample usage to review chosen api
> >
> > Code:
> >
> > ///test interleavedGeometry
> > InterleavedGeometry * igeom=new InterleavedGeometry();
> > igeom->setUseDisplayList(false);
> > igeom->setUseVertexBufferObjects(true);
> > igeom->setUseVertexArrayObject(true);
> >
> > struct example{
> > float pos[3],norm[3],texcoor[3],padding[3];//add 3 float padding for mem alignement
> > };
> > unsigned int stride=sizeof(struct example);
> > osg::ref_ptr<osg::BufferTemplate< std::vector<example> > > hostarray=new osg::BufferTemplate< std::vector<example> >;
> > hostarray->resize(4);
> > hostarray->setBinding(osg::Array::BIND_PER_VERTEX);
> > hostarray->setBufferObject(new osg::VertexBufferObject);
> > InterleavedGeometry::RangedBufferData *rbd=new InterleavedGeometry::RangedBufferData;
> > InterleavedGeometry::RangeDesc interleaveddesc;
> > interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,0));
> > interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,3*sizeof(GLfloat)));
> > interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,6*sizeof(GLfloat)));
> > igeom->addRangedBufferData(0,2,hostarray,interleaveddesc,stride );
> >
> > for(int j=0;j<2;j++){
> > for(int i=0;i<2;i++){
> > for(int k=0;k<3;k++){
> > float * fdata=igeom->getRangedBufferData(0)->data<float>(i*2+j,k);
> > *fdata++=float(i)*1.0f;
> > *fdata++=float(j)*1.0f;
> > *fdata++=0;
> > }
> > }
> > }
> >
> >
> >
> > Julien[/code]
> >
> > ------------------------
> > Twirling twirling twirling toward freedom
> >
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=75058#75058
> >
> >
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> >
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> ------------------
> Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75062#75062
More information about the osg-users
mailing list