[osg-users] About VBO in OSG

2011-05-09 Thread Ivan Shen
Hi, every:

I am very confused with the VBO in osg.
what is the euqal funcs to the codes followed in OSG?

  glGenBuffers(1, vboID);
  glBindBuffer(GL_ARRAY_BUFFER, *vboID);
  
  // initialize buffer object
  unsigned int size = mesh_width * mesh_height * typeSize;
  glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
  
  glBindBuffer(GL_ARRAY_BUFFER, 0);


I want to specify and use the vboID, but I dont know how to get the number.   

Thank you very much for your any reply
... 

Thank you!

Cheers,
shl

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39081#39081





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] About VBO in OSG

2011-05-09 Thread Ivan Shen
Hi, everyone,


I applied by this way,  does anyone have any more good idea?   



Code:
class MyDrawable : public osg::Drawable
{
public:
MyDrawable() {}

/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
MySmokeDrawable(const MyDrawable MyDrawable,const osg::CopyOp 
copyop=osg::CopyOp::SHALLOW_COPY):
osg::Drawable(MyDrawable,copyop) {}
META_Object(MyApp,MyDrawable)
virtual void drawImplementation(osg::RenderInfo renderInfo) const
{
osg::State* state = renderInfo.getState();
state-disableAllVertexArrays();

const osg::Drawable::Extensions* glExt = 
osg::Drawable::getExtensions(state-getContextID(), true);

//vbo create.
glExt-glGenBuffers(1, vboID);
glExt-glBindBuffer(GL_ARRAY_BUFFER_ARB, vboID);
glExt-glBufferData(GL_ARRAY_BUFFER_ARB, sizeof(Vertex)*24, 
NULL, GL_DYNAMIC_DRAW );
glExt-glBufferSubData(GL_ARRAY_BUFFER_ARB, 0, 
sizeof(Vertex)*24, verts);
state-setTexCoordPointer(0, 2, GL_FLOAT, sizeof(Vertex), 
BUFFER_OFFSET(12));
state-setNormalPointer(GL_FLOAT, sizeof(Vertex), 
BUFFER_OFFSET(20));
state-setColorPointer(4, GL_FLOAT, sizeof(Vertex), 
BUFFER_OFFSET(32));
state-setVertexPointer(3, GL_FLOAT, sizeof(Vertex), 
BUFFER_OFFSET(0));

glExt-glGenBuffers(1, indexVBOID);
glExt-glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, indexVBOID);
glExt-glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, 
36*sizeof(GLubyte), index, GL_STATIC_DRAW);


//  glGenBuffers(1, vboID); // Create the buffer ID, this is 
basically the same as generating texture ID's
//  glBindBuffer(GL_ARRAY_BUFFER, vboID); // Bind the buffer 
(vertex array data)
// 
//  glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * 24, NULL, 
GL_DYNAMIC_DRAW);
//  glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vertex) * 24, verts);
// 
// 
//  glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), 
BUFFER_OFFSET(12));
//  glNormalPointer(GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(20));
//  glColorPointer(4, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(32));
//  glVertexPointer(3, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(0));
// 
// 
//  glGenBuffers(1, indexVBOID); // Generate buffer
//  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBOID); // Bind the 
element array buffer
//  glBufferData(GL_ELEMENT_ARRAY_BUFFER, 36 * sizeof(GLubyte), 
index, GL_STATIC_DRAW);

//create donedo anything you want

...
...
}
}


such  as  :osg::geometry::useservertexbufferobject(true). and then specify the 
vbo no. or get the vbo no. from the geometry?

thank you for any reply!
... 

Thank you!

Cheers,
Ivan
Code:




--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39231#39231





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org