diff --git a/drape/glstate.cpp b/drape/glstate.cpp index 072a0237a6..f5f94d25cc 100644 --- a/drape/glstate.cpp +++ b/drape/glstate.cpp @@ -51,7 +51,6 @@ void ApplyUniforms(const UniformValuesStorage & uniforms, RefPointer void ApplyState(GLState state, RefPointer program) { TextureBinding & binding = state.GetTextureBinding(); - program->Bind(); if (binding.IsEnabled()) { int8_t textureLocation = program->GetUniformLocation(binding.GetUniformName()); diff --git a/drape/vertex_array_buffer.cpp b/drape/vertex_array_buffer.cpp index 00f181b393..e99c6216e4 100644 --- a/drape/vertex_array_buffer.cpp +++ b/drape/vertex_array_buffer.cpp @@ -33,7 +33,6 @@ void VertexArrayBuffer::Render() if (!m_buffers.empty()) { ASSERT(!m_program.IsNull(), ("Somebody not call Build. It's very bad. Very very bad")); - m_program->Bind(); /// if OES_vertex_array_object is supported than all bindings already saved in VAO /// and we need only bind VAO. In Bind method have ASSERT("bind already called") if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject)) diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 35d8521fb2..c2e654737e 100644 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -41,7 +41,10 @@ namespace df FlushTileMessage * msg = static_cast(message.GetRaw()); const GLState & state = msg->GetState(); const TileKey & key = msg->GetKey(); - MasterPointer buffer(msg->GetBuffer()); + MasterPointer buffer(msg->AcceptBuffer()); + RefPointer program = m_gpuProgramManager->GetProgram(state.GetProgramIndex()); + program->Bind(); + buffer->Build(program); render_data_t::iterator renderIterator = m_renderData.insert(make_pair(state, buffer)); m_tileData.insert(make_pair(key, renderIterator)); break; @@ -128,9 +131,9 @@ namespace df float m[4*4]; if (w >= h) - OrthoMatrix(m, -1.f/aspect, 2.f/aspect, -1.f, 2.f, -2.f, 2.f); + OrthoMatrix(m, -2.f/aspect, 2.f/aspect, -2.f, 2.f, -2.f, 2.f); else - OrthoMatrix(m, -1.f, 2.f, -1.f*aspect, 2.f*aspect, -2.f, 2.f); + OrthoMatrix(m, -2.f, 2.f, -2.f*aspect, 2.f*aspect, -2.f, 2.f); m_generalUniforms.SetMatrix4x4Value("projection", m); } @@ -154,6 +157,7 @@ namespace df { RefPointer program = m_gpuProgramManager->GetProgram(node.first.GetProgramIndex()); + program->Bind(); ApplyState(node.first, program); ApplyUniforms(m_generalUniforms, program); diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 8994aed65c..97da956b9b 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -8,8 +8,8 @@ #include "../drape/glstate.hpp" #include "../drape/pointers.hpp" +#include "../drape/vertex_array_buffer.hpp" -class VertexArrayBuffer; namespace threads { class IRoutine; } namespace df @@ -66,8 +66,13 @@ namespace df { } + ~FlushTileMessage() + { + m_buffer.Destroy(); + } + const GLState & GetState() const { return m_state; } - TransferPointer & GetBuffer() { return m_buffer; } + MasterPointer AcceptBuffer() { return MasterPointer(m_buffer); } private: GLState m_state;