Hi forum,
I am getting the invalid buffer object with the following source snippet:
Code:
.......................
.......................
osg::VertexBufferObject* vbo = _m_clGeomRef->getOrCreateVertexBufferObject();
if(!vbo)
{
osg::notify(osg::FATAL)
<< __FUNCTION__ <<": " << __LINE__ << ": "
<< _m_clGeomRef->getName() << ": no buffer object found."
<< std::endl;
return false;
} // END OF - !vbo
//get the context id
unsigned int contextID = osgCompute::GLMemory::getContext()->getState()->getContextID();
//compile vertex buffer
osg::GLBufferObject *glBO = vbo->getOrCreateGLBufferObject( contextID );
if( !glBO )
{
osg::notify(osg::FATAL)
<< __FUNCTION__ <<": " << __LINE__ << ": "
<< _m_clGeomRef->getName() << ": no GL buffer object found."
<< std::endl;
return false;
} // END OF - !glBO
if( glBO->isDirty())
{
osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions( osgCompute::GLMemory::getContext()->getState()->getContextID(),true);
if(!ext)
{
osg::notify(osg::FATAL)
<< __FUNCTION__ <<": " << __FUNCTION__ << ": "
<< _m_clGeomRef->getName() << ": cannot find required extensions to compile buffer object."
<< std::endl;
return false;
}
//the following function call the glBufferData()
glBO->compileBuffer();
//unbind the buffer objects
ext->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
ext->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
} // END OF - glBO->isDirty()
//avoid copy operation during osgCompute::MAP_HOST
memory._m_clLastModifiedCount.clear();
for( unsigned int d = 0; d < vbo->getNumBufferData(); ++d )
memory._m_clLastModifiedCount.push_back( vbo->getBufferData(d)->getModifiedCount());
GLuint objectid = glBO->getGLObjectID();
//create the vertex buffer from the gl buffer object
(memory._m_clDevBuffer) = clCreateFromGLBuffer(cxt->_m_clContext, // the valid opencl context
CL_MEM_READ_WRITE, // the memory has both the read and write access
objectid,
&errNum);
if( errNum != CL_SUCCESS )
{
osg::notify(osg::FATAL)
<< __FUNCTION__ <<": " << __LINE__ << ": "
<< _m_clGeomRef->getName() << ": unable to create opencl buffer object (clCreateFromGLBuffer): "
<< cxt->getErrorString(errNum) <<"."
<< std::endl;
return false;
}
.......................
.......................
As you can see that there is also one line of OpenCL code snippet where i am trying to create an OpenCL buffer from the OpenGL buffer object. But the buffer creation is not successful because the error string is telling that the
Code:
GLuint objectid = glBO->getGLObjectID();
is not returning the valid GL buffer object id or GL buffer object does not have an existing data store. I guess that i have to make it sure on the OSG side. AND this is where i seek your help.
Could you provide me with some hint to make sure that i got the valid GL buffer object and GL buffer object do have the existing data store. Please make some time to go through the code i have pasted above and let me know if i have missed something or at least where to look into.
Thank you!
Regards,
Sajjadul
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56774#56774
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org