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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-12-18 11:00:35 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-12-22 13:54:28 +0300
commit6d6e55da68cf142cf1da84138c46f82944746241 (patch)
tree9a1ccf8e9b0fc6985a9577926caa3d1efc01ed85 /drape_frontend/gui
parent14f162dd8a855a074b4ff2b5d90e310a99ff78fb (diff)
Button shader reorganization
Diffstat (limited to 'drape_frontend/gui')
-rw-r--r--drape_frontend/gui/button.cpp45
-rw-r--r--drape_frontend/gui/button.hpp9
2 files changed, 20 insertions, 34 deletions
diff --git a/drape_frontend/gui/button.cpp b/drape_frontend/gui/button.cpp
index 9c867ff090..4584d118c3 100644
--- a/drape_frontend/gui/button.cpp
+++ b/drape_frontend/gui/button.cpp
@@ -36,15 +36,13 @@ uint32_t BuildRect(vector<Button::ButtonVertex> & vertices,
glsl::vec2 const & v3, glsl::vec2 const & v4)
{
- glsl::vec3 const position(0.0f, 0.0f, 0.0f);
+ vertices.push_back(Button::ButtonVertex(v1));
+ vertices.push_back(Button::ButtonVertex(v2));
+ vertices.push_back(Button::ButtonVertex(v3));
- vertices.push_back(Button::ButtonVertex(position, v1));
- vertices.push_back(Button::ButtonVertex(position, v2));
- vertices.push_back(Button::ButtonVertex(position, v3));
-
- vertices.push_back(Button::ButtonVertex(position, v3));
- vertices.push_back(Button::ButtonVertex(position, v2));
- vertices.push_back(Button::ButtonVertex(position, v4));
+ vertices.push_back(Button::ButtonVertex(v3));
+ vertices.push_back(Button::ButtonVertex(v2));
+ vertices.push_back(Button::ButtonVertex(v4));
return dp::Batcher::IndexPerQuad;
}
@@ -53,23 +51,21 @@ uint32_t BuildCorner(vector<Button::ButtonVertex> & vertices,
glsl::vec2 const & pt, double radius,
double angleStart, double angleFinish)
{
- glsl::vec3 const position(0.0f, 0.0f, 0.0f);
-
- int const trianglesCount = 8;
- double const sector = (angleFinish - angleStart) / static_cast<double>(trianglesCount);
+ int const kTrianglesCount = 8;
+ double const sector = (angleFinish - angleStart) / kTrianglesCount;
m2::PointD startNormal(0.0f, radius);
- for (size_t i = 0; i < trianglesCount; ++i)
+ for (size_t i = 0; i < kTrianglesCount; ++i)
{
m2::PointD normal = m2::Rotate(startNormal, angleStart + i * sector);
m2::PointD nextNormal = m2::Rotate(startNormal, angleStart + (i + 1) * sector);
- vertices.push_back(Button::ButtonVertex(position, pt));
- vertices.push_back(Button::ButtonVertex(position, pt - glsl::ToVec2(normal)));
- vertices.push_back(Button::ButtonVertex(position, pt - glsl::ToVec2(nextNormal)));
+ vertices.push_back(Button::ButtonVertex(pt));
+ vertices.push_back(Button::ButtonVertex(pt - glsl::ToVec2(normal)));
+ vertices.push_back(Button::ButtonVertex(pt - glsl::ToVec2(nextNormal)));
}
- return trianglesCount * dp::Batcher::IndexPerTriangle;
+ return kTrianglesCount * dp::Batcher::IndexPerTriangle;
}
}
@@ -189,21 +185,14 @@ dp::BindingInfo const & Button::ButtonVertex::GetBindingInfo()
if (info == nullptr)
{
- info.reset(new dp::BindingInfo(2));
-
- dp::BindingDecl & posDecl = info->GetBindingDecl(0);
- posDecl.m_attributeName = "a_position";
- posDecl.m_componentCount = 3;
- posDecl.m_componentType = gl_const::GLFloatType;
- posDecl.m_offset = 0;
- posDecl.m_stride = sizeof(ButtonVertex);
+ info.reset(new dp::BindingInfo(1));
- dp::BindingDecl & normalDecl = info->GetBindingDecl(1);
+ dp::BindingDecl & normalDecl = info->GetBindingDecl(0);
normalDecl.m_attributeName = "a_normal";
normalDecl.m_componentCount = 2;
normalDecl.m_componentType = gl_const::GLFloatType;
- normalDecl.m_offset = sizeof(glsl::vec3);
- normalDecl.m_stride = posDecl.m_stride;
+ normalDecl.m_offset = 0;
+ normalDecl.m_stride = sizeof(ButtonVertex);
}
return *info.get();
diff --git a/drape_frontend/gui/button.hpp b/drape_frontend/gui/button.hpp
index 193e6db78b..087cc676dd 100644
--- a/drape_frontend/gui/button.hpp
+++ b/drape_frontend/gui/button.hpp
@@ -33,15 +33,12 @@ public:
struct ButtonVertex
{
ButtonVertex() = default;
- ButtonVertex(glsl::vec3 const & position, glsl::vec2 const & normal)
- : m_position(position)
- , m_normal(normal)
- {
- }
+ ButtonVertex(glsl::vec2 const & normal)
+ : m_normal(normal)
+ {}
static dp::BindingInfo const & GetBindingInfo();
- glsl::vec3 m_position;
glsl::vec2 m_normal;
};