forked from organicmaps/organicmaps
Unbind VAO after each binding.
This commit is contained in:
parent
601a2b9a14
commit
e956ba3c5b
2 changed files with 25 additions and 8 deletions
|
@ -79,14 +79,14 @@ void VertexArrayBuffer::RenderRange(IndicesRange const & range)
|
|||
ASSERT(m_program != nullptr, ("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
|
||||
/// and we need only bind VAO.
|
||||
if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
Bind();
|
||||
else
|
||||
if (!Bind())
|
||||
BindStaticBuffers();
|
||||
|
||||
BindDynamicBuffers();
|
||||
GetIndexBuffer()->Bind();
|
||||
GLFunctions::glDrawElements(dp::IndexStorage::SizeOfIndex(), range.m_idxCount, range.m_idxStart);
|
||||
|
||||
Unbind();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,7 @@ void VertexArrayBuffer::Build(ref_ptr<GpuProgram> program)
|
|||
m_VAO = GLFunctions::glGenVertexArray();
|
||||
Bind();
|
||||
BindStaticBuffers();
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void VertexArrayBuffer::UploadData(BindingInfo const & bindingInfo, void const * data, uint32_t count)
|
||||
|
@ -232,8 +233,7 @@ void VertexArrayBuffer::ApplyMutation(ref_ptr<IndexBufferMutator> indexMutator,
|
|||
{
|
||||
/// We need to bind current VAO before calling glBindBuffer if OES_vertex_array_object is supported.
|
||||
/// Otherwise we risk affecting a previously binded VAO.
|
||||
if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
Bind();
|
||||
Bind();
|
||||
|
||||
if (indexMutator != nullptr)
|
||||
{
|
||||
|
@ -247,7 +247,10 @@ void VertexArrayBuffer::ApplyMutation(ref_ptr<IndexBufferMutator> indexMutator,
|
|||
}
|
||||
|
||||
if (attrMutator == nullptr)
|
||||
{
|
||||
Unbind();
|
||||
return;
|
||||
}
|
||||
|
||||
typedef AttributeBufferMutator::TMutateData TMutateData;
|
||||
typedef AttributeBufferMutator::TMutateNodes TMutateNodes;
|
||||
|
@ -266,12 +269,25 @@ void VertexArrayBuffer::ApplyMutation(ref_ptr<IndexBufferMutator> indexMutator,
|
|||
mapper.UpdateData(node.m_data.get(), node.m_region.m_offset, node.m_region.m_count);
|
||||
}
|
||||
}
|
||||
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void VertexArrayBuffer::Bind() const
|
||||
bool VertexArrayBuffer::Bind() const
|
||||
{
|
||||
ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render"));
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
{
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VertexArrayBuffer::Unbind() const
|
||||
{
|
||||
if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void VertexArrayBuffer::BindStaticBuffers() const
|
||||
|
|
|
@ -76,7 +76,8 @@ private:
|
|||
|
||||
ref_ptr<DataBuffer> GetOrCreateBuffer(BindingInfo const & bindingInfo, bool isDynamic);
|
||||
ref_ptr<DataBuffer> GetBuffer(BindingInfo const & bindingInfo, bool isDynamic) const;
|
||||
void Bind() const;
|
||||
bool Bind() const;
|
||||
void Unbind() const;
|
||||
void BindStaticBuffers() const;
|
||||
void BindDynamicBuffers() const;
|
||||
void BindBuffers(TBuffersMap const & buffers) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue