diff --git a/drape_frontend/area_shape.cpp b/drape_frontend/area_shape.cpp new file mode 100644 index 0000000000..b6813c1749 --- /dev/null +++ b/drape_frontend/area_shape.cpp @@ -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) const + { + GLState state(gpu::SOLID_AREA_PROGRAM, 0, TextureBinding("", false, 0, MakeStackRefPointer(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 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)); + } +} diff --git a/drape_frontend/area_shape.hpp b/drape_frontend/area_shape.hpp new file mode 100644 index 0000000000..1d13aa4a98 --- /dev/null +++ b/drape_frontend/area_shape.hpp @@ -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) const; + + private: + Color m_color; + vector m_vertexes; + }; +} diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro index c9aa75cd93..41481068bf 100644 --- a/drape_frontend/drape_frontend.pro +++ b/drape_frontend/drape_frontend.pro @@ -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