diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2015-04-02 19:46:16 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2015-11-30 16:04:14 +0300 |
commit | 559220a68738ae6e6696ffb4d71f6d0110b09917 (patch) | |
tree | 6c5b39e618507cc46941de36749894240612d144 /drape/vertex_array_buffer.cpp | |
parent | 31067b916db841066c2107114fff77ec8437a29c (diff) |
review fixes
Diffstat (limited to 'drape/vertex_array_buffer.cpp')
-rw-r--r-- | drape/vertex_array_buffer.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp index b6cd98c602..2146043a94 100644 --- a/drape/vertex_array_buffer.cpp +++ b/drape/vertex_array_buffer.cpp @@ -41,6 +41,7 @@ void VertexArrayBuffer::Preflush() for(auto & buffer : m_dynamicBuffers) buffer.second->MoveToGPU(GPUBuffer::ElementBuffer); + ASSERT(!m_indexBuffer.IsNull(), ()); m_indexBuffer->MoveToGPU(GPUBuffer::IndexBuffer); GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); @@ -49,12 +50,12 @@ void VertexArrayBuffer::Preflush() void VertexArrayBuffer::Render() { - RenderRange(IndicesRange{ 0, m_indexBuffer->GetBuffer()->GetCurrentSize() }); + RenderRange({ 0, GetIndexBuffer().GetCurrentSize() }); } void VertexArrayBuffer::RenderRange(IndicesRange const & range) { - if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty()) && m_indexBuffer->GetBuffer()->GetCurrentSize() > 0) + if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty()) && GetIndexCount() > 0) { ASSERT(!m_program.IsNull(), ("Somebody not call Build. It's very bad. Very very bad")); /// if OES_vertex_array_object is supported than all bindings already saved in VAO @@ -65,7 +66,7 @@ void VertexArrayBuffer::RenderRange(IndicesRange const & range) BindStaticBuffers(); BindDynamicBuffers(); - m_indexBuffer->GetBuffer()->Bind(); + GetIndexBuffer().Bind(); GLFunctions::glDrawElements(range.m_idxCount, range.m_idxStart); } } @@ -148,7 +149,7 @@ RefPointer<DataBuffer> VertexArrayBuffer::GetOrCreateBuffer(BindingInfo const & uint16_t VertexArrayBuffer::GetAvailableIndexCount() const { - return m_indexBuffer->GetBuffer()->GetAvailableSize(); + return GetIndexBuffer().GetAvailableSize(); } uint16_t VertexArrayBuffer::GetAvailableVertexCount() const @@ -188,7 +189,7 @@ uint16_t VertexArrayBuffer::GetDynamicBufferOffset(BindingInfo const & bindingIn uint16_t VertexArrayBuffer::GetIndexCount() const { - return m_indexBuffer->GetBuffer()->GetCurrentSize(); + return GetIndexBuffer().GetCurrentSize(); } bool VertexArrayBuffer::IsFilled() const @@ -198,15 +199,18 @@ bool VertexArrayBuffer::IsFilled() const void VertexArrayBuffer::UploadIndexes(uint16_t const * data, uint16_t count) { - ASSERT(count <= m_indexBuffer->GetBuffer()->GetAvailableSize(), ()); - m_indexBuffer->UploadData(data, count); + ASSERT(count <= GetIndexBuffer().GetAvailableSize(), ()); + GetIndexBuffer().UploadData(data, count); } void VertexArrayBuffer::ApplyMutation(RefPointer<IndexBufferMutator> indexMutator, RefPointer<AttributeBufferMutator> attrMutator) { if (!indexMutator.IsNull()) + { + ASSERT(!m_indexBuffer.IsNull(), ()); m_indexBuffer->UpdateData(indexMutator->GetIndexes(), indexMutator->GetIndexCount()); + } if (attrMutator.IsNull()) return; @@ -271,4 +275,16 @@ void VertexArrayBuffer::BindBuffers(TBuffersMap const & buffers) const } } +DataBufferBase & VertexArrayBuffer::GetIndexBuffer() +{ + ASSERT(!m_indexBuffer.IsNull(), ()); + return *(m_indexBuffer->GetBuffer().GetRaw()); +} + +DataBufferBase const & VertexArrayBuffer::GetIndexBuffer() const +{ + ASSERT(!m_indexBuffer.IsNull(), ()); + return *(m_indexBuffer->GetBuffer().GetRaw()); +} + } // namespace dp |