[drape] all structures rely that correct gpu program already binded

This commit is contained in:
ExMix 2014-01-10 12:56:03 +03:00 committed by Alex Zolotarev
parent 0f0d79fc26
commit 7e232d12d7
4 changed files with 14 additions and 7 deletions

View file

@ -51,7 +51,6 @@ void ApplyUniforms(const UniformValuesStorage & uniforms, RefPointer<GpuProgram>
void ApplyState(GLState state, RefPointer<GpuProgram> program)
{
TextureBinding & binding = state.GetTextureBinding();
program->Bind();
if (binding.IsEnabled())
{
int8_t textureLocation = program->GetUniformLocation(binding.GetUniformName());

View file

@ -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))

View file

@ -41,7 +41,10 @@ namespace df
FlushTileMessage * msg = static_cast<FlushTileMessage *>(message.GetRaw());
const GLState & state = msg->GetState();
const TileKey & key = msg->GetKey();
MasterPointer<VertexArrayBuffer> buffer(msg->GetBuffer());
MasterPointer<VertexArrayBuffer> buffer(msg->AcceptBuffer());
RefPointer<GpuProgram> 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<GpuProgram> program = m_gpuProgramManager->GetProgram(node.first.GetProgramIndex());
program->Bind();
ApplyState(node.first, program);
ApplyUniforms(m_generalUniforms, program);

View file

@ -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<VertexArrayBuffer> & GetBuffer() { return m_buffer; }
MasterPointer<VertexArrayBuffer> AcceptBuffer() { return MasterPointer<VertexArrayBuffer>(m_buffer); }
private:
GLState m_state;