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

Method CommitVertices

Sources/nCine/Graphics/Geometry.cpp:222–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 }
221
222 void Geometry::CommitVertices()
223 {
224 if (hostVertexPointer_ != nullptr && hasDirtyVertices_) {
225 // Checking if the common VBO is allowed to use mapping and do the same for the custom one
226 const GLenum mapFlags = RenderResources::GetBuffersManager().Specs(RenderBuffersManager::BufferTypes::Array).mapFlags;
227 const std::uint32_t numFloats = numVertices_ * numElementsPerVertex_;
228
229 if (mapFlags == 0 && vbo_ != nullptr) {
230 // Using buffer orphaning + `glBufferSubData()` when having a custom VBO with no mapping available
231 vbo_->BufferData(vboParams_.size, nullptr, vboUsageFlags_);
232 vbo_->BufferSubData(vboParams_.offset, vboParams_.size, hostVertexPointer_);
233 } else {
234 GLfloat* vertices = vbo_ ? AcquireVertexPointer() : AcquireVertexPointer(numFloats, numElementsPerVertex_);
235 memcpy(vertices, hostVertexPointer_, numFloats * sizeof(GLfloat));
236 ReleaseVertexPointer();
237 }
238
239 // The dirty flag is only useful with a custom VBO. If the render command uses the common one, it must always copy vertices.
240 if (vbo_ != nullptr) {
241 hasDirtyVertices_ = false;
242 }
243 }
244 }
245
246 void Geometry::CommitIndices()
247 {

Callers 1

CommitAllMethod · 0.80

Calls 2

BufferDataMethod · 0.80
BufferSubDataMethod · 0.80

Tested by

no test coverage detected