Welcome to mirror list, hosted at ThFree Co, Russian Federation.

area_shape.cpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f9568f7db2def2e819f64e30a20898ddf90d3ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "drape_frontend/area_shape.hpp"

#include "drape/shader_def.hpp"
#include "drape/glstate.hpp"
#include "drape/batcher.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/texture_manager.hpp"
#include "drape/utils/vertex_decl.hpp"

#include "base/buffer_vector.hpp"
#include "base/logging.hpp"

#include "std/algorithm.hpp"

namespace df
{

AreaShape::AreaShape(vector<m2::PointF> && triangleList, AreaViewParams const & params)
  : m_vertexes(triangleList)
  , m_params(params)
{
}

void AreaShape::Draw(dp::RefPointer<dp::Batcher> batcher, dp::RefPointer<dp::TextureManager> textures) const
{
  dp::TextureManager::ColorRegion region;
  textures->GetColorRegion(m_params.m_color, region);
  glsl::vec2 const colorPoint = glsl::ToVec2(region.GetTexRect().Center());

  buffer_vector<gpu::SolidTexturingVertex, 128> vertexes;
  vertexes.resize(m_vertexes.size());
  transform(m_vertexes.begin(), m_vertexes.end(), vertexes.begin(), [&colorPoint, this](m2::PointF const & vertex)
  {
    return gpu::SolidTexturingVertex(glsl::vec3(glsl::ToVec2(vertex), m_params.m_depth),
                                     glsl::vec2(0.0, 0.0),
                                     colorPoint);
  });

  dp::GLState state(gpu::TEXTURING_PROGRAM, dp::GLState::GeometryLayer);
  state.SetColorTexture(region.GetTexture());

  dp::AttributeProvider provider(1, m_vertexes.size());
  provider.InitStream(0, gpu::SolidTexturingVertex::GetBindingInfo(), dp::MakeStackRefPointer<void>(vertexes.data()));
  batcher->InsertTriangleList(state, dp::MakeStackRefPointer(&provider));
}

} // namespace df