| 103 | } // namespace |
| 104 | |
| 105 | drape_ptr<ShapeRenderer> Compass::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex, |
| 106 | TTapHandler const & tapHandler) const |
| 107 | { |
| 108 | dp::TextureManager::SymbolRegion region; |
| 109 | tex->GetSymbolRegion("compass", region); |
| 110 | auto const halfSize = glsl::ToVec2(region.GetPixelSize() * 0.5f); |
| 111 | auto const texRect = region.GetTexRect(); |
| 112 | |
| 113 | ASSERT_EQUAL(m_position.m_anchor, dp::Center, ()); |
| 114 | CompassVertex vertexes[] = {CompassVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())), |
| 115 | CompassVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())), |
| 116 | CompassVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())), |
| 117 | CompassVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))}; |
| 118 | |
| 119 | auto state = df::CreateRenderState(gpu::Program::TexturingGui, df::DepthLayer::GuiLayer); |
| 120 | state.SetColorTexture(region.GetTexture()); |
| 121 | state.SetDepthTestEnabled(false); |
| 122 | state.SetTextureIndex(region.GetTextureIndex()); |
| 123 | |
| 124 | dp::AttributeProvider provider(1, 4); |
| 125 | dp::BindingInfo info(2); |
| 126 | |
| 127 | dp::BindingDecl & posDecl = info.GetBindingDecl(0); |
| 128 | posDecl.m_attributeName = "a_position"; |
| 129 | posDecl.m_componentCount = 2; |
| 130 | posDecl.m_componentType = gl_const::GLFloatType; |
| 131 | posDecl.m_offset = 0; |
| 132 | posDecl.m_stride = sizeof(CompassVertex); |
| 133 | |
| 134 | dp::BindingDecl & texDecl = info.GetBindingDecl(1); |
| 135 | texDecl.m_attributeName = "a_colorTexCoords"; |
| 136 | texDecl.m_componentCount = 2; |
| 137 | texDecl.m_componentType = gl_const::GLFloatType; |
| 138 | texDecl.m_offset = sizeof(glsl::vec2); |
| 139 | texDecl.m_stride = posDecl.m_stride; |
| 140 | |
| 141 | provider.InitStream(0, info, make_ref(&vertexes)); |
| 142 | |
| 143 | drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CompassHandle>( |
| 144 | EGuiHandle::GuiHandleCompass, m_position.m_pixelPivot, region.GetPixelSize(), tapHandler); |
| 145 | |
| 146 | drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>(); |
| 147 | dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad); |
| 148 | batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default)); |
| 149 | dp::SessionGuard guard(context, batcher, std::bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2)); |
| 150 | batcher.InsertTriangleStrip(context, state, make_ref(&provider), std::move(handle)); |
| 151 | |
| 152 | return renderer; |
| 153 | } |
| 154 | } // namespace gui |
nothing calls this directly
no test coverage detected