[drape] simple area shape for debug

This commit is contained in:
ExMix 2013-12-27 15:56:10 +03:00 committed by Alex Zolotarev
parent 934f4aa080
commit 9007fbe744
3 changed files with 87 additions and 2 deletions

View file

@ -0,0 +1,55 @@
#include "area_shape.hpp"
#include "../drape/shader_def.hpp"
#include "../drape/attribute_provider.hpp"
namespace df
{
AreaShape::AreaShape(const Color & c)
: m_color(c)
{
}
void AreaShape::AddTriangle(const m2::PointF & v1,
const m2::PointF & v2,
const m2::PointF & v3)
{
m_vertexes.push_back(v1);
m_vertexes.push_back(v2);
m_vertexes.push_back(v3);
}
void AreaShape::Draw(RefPointer<Batcher> batcher) const
{
GLState state(gpu::SOLID_AREA_PROGRAM, 0, TextureBinding("", false, 0, MakeStackRefPointer<Texture>(NULL)));
float r, g, b, a;
Convert(m_color, r, g, b, a);
state.GetUniformValues().SetFloatValue("color", r, g, b, a);
AttributeProvider provider(2, m_vertexes.size());
{
BindingInfo info(1);
BindingDecl & decl = info.GetBindingDecl(0);
decl.m_attributeName = "position";
decl.m_componentCount = 2;
decl.m_componentType = GLConst::GLFloatType;
decl.m_offset = 0;
decl.m_stride = 0;
provider.InitStream(0, info, MakeStackRefPointer((void *)&m_vertexes[0]));
}
vector<float> depthMemory(m_vertexes.size(), 0.0);
{
BindingInfo info(1);
BindingDecl & decl = info.GetBindingDecl(0);
decl.m_attributeName = "depth";
decl.m_componentCount = 1;
decl.m_componentType = GLConst::GLFloatType;
decl.m_offset = 0;
decl.m_stride = 0;
provider.InitStream(0, info, MakeStackRefPointer((void *)&depthMemory[0]));
}
batcher->InsertTriangleList(state, MakeStackRefPointer(&provider));
}
}

View file

@ -0,0 +1,28 @@
#pragma once
#include "map_shape.hpp"
#include "../drape/batcher.hpp"
#include "../drape/pointers.hpp"
#include "../drape/color.hpp"
#include "../geometry/point2d.hpp"
#include "../std/vector.hpp"
namespace df
{
class AreaShape : public MapShape
{
public:
AreaShape(Color const & c);
void AddTriangle(const m2::PointF & v1,
const m2::PointF & v2,
const m2::PointF & v3);
virtual void Draw(RefPointer<Batcher> batcher) const;
private:
Color m_color;
vector<m2::PointF> m_vertexes;
};
}

View file

@ -17,7 +17,8 @@ SOURCES += \
impl/backend_renderer_impl.cpp \
read_mwm_task.cpp \
batchers_pool.cpp \
frontend_renderer.cpp
frontend_renderer.cpp \
area_shape.cpp
HEADERS += \
backend_renderer.hpp \
@ -34,4 +35,5 @@ HEADERS += \
message_subclasses.hpp \
map_shape.hpp \
batchers_pool.hpp \
frontend_renderer.hpp
frontend_renderer.hpp \
area_shape.hpp