示例#1
0
  void ShapeRenderer::drawRectangle(m2::AnyRectD const & r, graphics::Color const & c, double depth)
  {
    uint32_t id = base_t::mapInfo(Brush::Info(c));
    Resource const * res = base_t::fromID(id);

    if (res == 0)
    {
      LOG(LDEBUG, ("cannot map color"));
      return;
    }

    m2::PointD rectPts[4];

    r.GetGlobalPoints(rectPts);
    swap(rectPts[2], rectPts[3]);

    m2::PointF rectPtsF[4];
    for (int i = 0; i < 4; ++i)
      rectPtsF[i] = m2::PointF(rectPts[i].x, rectPts[i].y);

    GeometryPipeline & p = pipeline(res->m_pipelineID);

    shared_ptr<gl::BaseTexture> texture = p.texture();

    if (!texture)
    {
      LOG(LDEBUG, ("returning as no texture is reserved"));
      return;
    }

    m2::PointF texPt = texture->mapPixel(m2::RectF(res->m_texRect).Center());

    m2::PointF normal(0, 0);

    addTexturedStripStrided(
          rectPtsF,
          sizeof(m2::PointF),
          &normal,
          0,
          &texPt,
          0,
          4,
          depth,
          res->m_pipelineID);
  }