本文整理汇总了C++中ref_ptr::GetSymbolRegion方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::GetSymbolRegion方法的具体用法?C++ ref_ptr::GetSymbolRegion怎么用?C++ ref_ptr::GetSymbolRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::GetSymbolRegion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: provider
drape_ptr<ShapeRenderer> Watermark::Draw(ref_ptr<dp::GraphicsContext> context, m2::PointF & size,
ref_ptr<dp::TextureManager> tex) const
{
dp::TextureManager::SymbolRegion region;
tex->GetSymbolRegion("watermark", region);
glsl::vec2 const halfSize = glsl::ToVec2(region.GetPixelSize() * 0.5f);
m2::RectF const texRect = region.GetTexRect();
WatermarkVertex vertexes[] =
{
WatermarkVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())),
WatermarkVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())),
WatermarkVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())),
WatermarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))
};
auto state = df::CreateRenderState(gpu::Program::TexturingGui, df::DepthLayer::GuiLayer);
state.SetColorTexture(region.GetTexture());
state.SetDepthTestEnabled(false);
dp::AttributeProvider provider(1 /* streamCount */, 4 /* vertexCount */);
dp::BindingInfo info(2 /* count */);
dp::BindingDecl & posDecl = info.GetBindingDecl(0);
posDecl.m_attributeName = "a_position";
posDecl.m_componentCount = 2;
posDecl.m_componentType = gl_const::GLFloatType;
posDecl.m_offset = 0;
posDecl.m_stride = sizeof(WatermarkVertex);
dp::BindingDecl & texDecl = info.GetBindingDecl(1);
texDecl.m_attributeName = "a_colorTexCoords";
texDecl.m_componentCount = 2;
texDecl.m_componentType = gl_const::GLFloatType;
texDecl.m_offset = sizeof(glsl::vec2);
texDecl.m_stride = posDecl.m_stride;
provider.InitStream(0, info, make_ref(&vertexes));
size = region.GetPixelSize();
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<WatermarkVertexHandle>(
EGuiHandle::GuiHandleWatermark, m_position.m_pixelPivot, m_position.m_anchor, size);
drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad);
batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default));
dp::SessionGuard guard(context, batcher, std::bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2));
batcher.InsertTriangleStrip(context, state, make_ref(&provider), std::move(handle));
return renderer;
}