本文整理汇总了C++中Extensions::glBufferSubData方法的典型用法代码示例。如果您正苦于以下问题:C++ Extensions::glBufferSubData方法的具体用法?C++ Extensions::glBufferSubData怎么用?C++ Extensions::glBufferSubData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extensions
的用法示例。
在下文中一共展示了Extensions::glBufferSubData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileBuffer
void ElementBufferObject::compileBuffer(State& state) const
{
unsigned int contextID = state.getContextID();
_compiledList[contextID] = 1;
// osg::notify(osg::NOTICE)<<"ElementBufferObject::compile"<<std::endl;
Extensions* extensions = getExtensions(contextID,true);
unsigned int totalSizeRequired = 0;
// unsigned int numModified = 0;
// unsigned int numNotModified = 0;
for(BufferEntryDrawElementsPairs::const_iterator itr = _bufferEntryDrawElementsPairs.begin();
itr != _bufferEntryDrawElementsPairs.end();
++itr)
{
const BufferEntryDrawElementsPair& bep = *itr;
if (bep.second)
{
totalSizeRequired += bep.second->getTotalDataSize();
}
}
bool copyAll = false;
GLuint& ebo = buffer(contextID);
if (ebo==0)
{
// building for the first time.
_totalSize = totalSizeRequired;
// don't generate buffer if size is zero.
if (_totalSize==0) return;
extensions->glGenBuffers(1, &ebo);
extensions->glBindBuffer(_target, ebo);
extensions->glBufferData(_target, _totalSize, NULL, _usage);
copyAll = true;
}
else
{
extensions->glBindBuffer(_target, ebo);
if (_totalSize != totalSizeRequired)
{
// resize EBO.
_totalSize = totalSizeRequired;
extensions->glBufferData(_target, _totalSize, NULL, _usage);
copyAll = true;
}
}
// osg::Timer_t start_tick = osg::Timer::instance()->tick();
void* eboMemory = 0;
#if 0
eboMemory = extensions->glMapBuffer(_target, GL_WRITE_ONLY_ARB);
#endif
size_t offset = 0;
for(BufferEntryDrawElementsPairs::const_iterator itr = _bufferEntryDrawElementsPairs.begin();
itr != _bufferEntryDrawElementsPairs.end();
++itr)
{
const BufferEntryDrawElementsPair& bep = *itr;
const DrawElements* de = bep.second;
if (de)
{
if (copyAll ||
bep.first.modifiedCount[contextID] != bep.second->getModifiedCount() ||
bep.first.dataSize != bep.second->getTotalDataSize())
{
// copy data across
bep.first.dataSize = bep.second->getTotalDataSize();
bep.first.modifiedCount[contextID] = de->getModifiedCount();
if (copyAll)
{
bep.first.offset = offset;
de->setElementBufferObjectOffset((GLvoid*)offset);
offset += bep.first.dataSize;
}
if (eboMemory)
memcpy((char*)eboMemory + bep.first.offset, de->getDataPointer(), bep.first.dataSize);
else
extensions->glBufferSubData(_target, bep.first.offset, bep.first.dataSize, de->getDataPointer());
}
}
}
// Unmap the texture image buffer
if (eboMemory) extensions->glUnmapBuffer(_target);
//.........这里部分代码省略.........