本文整理汇总了C++中Extensions::glGenBuffers方法的典型用法代码示例。如果您正苦于以下问题:C++ Extensions::glGenBuffers方法的具体用法?C++ Extensions::glGenBuffers怎么用?C++ Extensions::glGenBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extensions
的用法示例。
在下文中一共展示了Extensions::glGenBuffers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileBuffer
void PixelBufferObject::compileBuffer(State& state) const
{
unsigned int contextID = state.getContextID();
_compiledList[contextID] = 1;
osg::Image* image = _bufferEntryImagePair.second;
_bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
if (!image->valid()) return;
Extensions* extensions = getExtensions(contextID,true);
GLuint& pbo = buffer(contextID);
if (pbo==0)
{
// building for the first time.
_totalSize = image->getTotalSizeInBytes();
// don't generate buffer if size is zero.
if (_totalSize==0) return;
extensions->glGenBuffers(1, &pbo);
extensions->glBindBuffer(_target, pbo);
extensions->glBufferData(_target, _totalSize, NULL, _usage);
}
else
{
extensions->glBindBuffer(_target, pbo);
if (_totalSize != image->getTotalSizeInBytes())
{
// resize PBO.
_totalSize = image->getTotalSizeInBytes();
extensions->glBufferData(_target, _totalSize, NULL, _usage);
}
}
// osg::Timer_t start_tick = osg::Timer::instance()->tick();
void* pboMemory = extensions->glMapBuffer(_target,
GL_WRITE_ONLY_ARB);
// copy data across
memcpy(pboMemory, image->data(), _totalSize);
// Unmap the texture image buffer
extensions->glUnmapBuffer(_target);
_bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
// osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
// osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
}