MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / CommitIndices

Method CommitIndices

Sources/nCine/Graphics/Geometry.cpp:246–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244 }
245
246 void Geometry::CommitIndices()
247 {
248 if (hostIndexPointer_ != nullptr && hasDirtyIndices_) {
249 // Checking if the common IBO is allowed to use mapping and do the same for the custom one
250 const GLenum mapFlags = RenderResources::GetBuffersManager().Specs(RenderBuffersManager::BufferTypes::ElementArray).mapFlags;
251
252 if (mapFlags == 0 && ibo_ != nullptr) {
253 // Using buffer orphaning + `glBufferSubData()` when having a custom IBO with no mapping available
254 ibo_->BufferData(iboParams_.size, nullptr, iboUsageFlags_);
255 ibo_->BufferSubData(iboParams_.offset, iboParams_.size, hostIndexPointer_);
256 } else {
257 GLushort* indices = ibo_ ? AcquireIndexPointer() : AcquireIndexPointer(numIndices_);
258 memcpy(indices, hostIndexPointer_, numIndices_ * sizeof(GLushort));
259 ReleaseIndexPointer();
260 }
261
262 // The dirty flag is only useful with a custom IBO. If the render command uses the common one, it must always copy indices.
263 if (ibo_ != nullptr) {
264 hasDirtyIndices_ = false;
265 }
266 }
267 }
268}

Callers 1

CommitAllMethod · 0.80

Calls 2

BufferDataMethod · 0.80
BufferSubDataMethod · 0.80

Tested by

no test coverage detected