Exemplo n.º 1
0
void PrimitiveShader_PC::drawLine(const Mat3 &transform, const Vec2 &p0, const Vec2 &p1)
{
    prepare(DrawMode::LINES);
    auto q = transform * Vec3(p0,1);
    buffer_.push_back(Point{Vec2(q), getColor4()});
    q = transform * Vec3(p1,1);
    buffer_.push_back(Point{Vec2(q), getColor4()});
}
Exemplo n.º 2
0
void PrimitiveShader_PC::drawTriangleStrip(const Mat3 &transform, const Vec2 *points, size_t n)
{
    prepare(DrawMode::TRIANGLES);
    int triangles = n-2;
    int N = buffer_.size();
    buffer_.resize(N+3*triangles);
    auto p = &buffer_[N];
    auto const &color = getColor4();
    auto half = triangles>>1;
    for(int i=0; i<half; i++){
        *p++ = Point{transform_helper(transform, points[0]), color};
        *p++ = Point{transform_helper(transform, points[1]), color};
        *p++ = Point{transform_helper(transform, points[2]), color};
        points++;
        *p++ = Point{transform_helper(transform, points[1]), color};
        *p++ = Point{transform_helper(transform, points[0]), color};
        *p++ = Point{transform_helper(transform, points[2]), color};
        points++;
    }
    if(half*2 != triangles){
       *p++ = Point{transform_helper(transform, points[0]), color};
       *p++ = Point{transform_helper(transform, points[1]), color};
       *p++ = Point{transform_helper(transform, points[2]), color};
    }
}
Exemplo n.º 3
0
void PrimitiveShader_PC::drawTriangleStrip(const Vec2 *points, size_t n)
{
    prepare(DrawMode::TRIANGLES);
    int triangles = n-2;
    int N = buffer_.size();
    buffer_.resize(N+3*triangles);
    auto p = &buffer_[N];
    auto const &color = getColor4();
    auto half = triangles>>1;
    for(int i=0; i<half; i++){
        p->pos = points[0]; p->color = color; p++;
        p->pos = points[1]; p->color = color; p++;
        p->pos = points[2]; p->color = color; p++;
        points++;

        p->pos = points[1]; p->color = color; p++;
        p->pos = points[0]; p->color = color; p++;
        p->pos = points[2]; p->color = color; p++;
        points++;
    }
    if(half*2 != triangles){
        p->pos = points[0]; p->color = color; p++;
        p->pos = points[1]; p->color = color; p++;
        p->pos = points[2]; p->color = color;
    }
}
Exemplo n.º 4
0
void PrimitiveShader_PC::drawLineLoop(const Vec2 *points, size_t n)
{
    drawLineStrip(points, n);
    int N = buffer_.size();
    buffer_.resize(N+2);
    auto p = &buffer_[N];
    p[0].pos = points[n-1];
    p[1].pos = points[0];
    p[0].color = p[1].color = getColor4();
}
Exemplo n.º 5
0
void PrimitiveShader_PC::drawTriangleFan(const Vec2 *points, size_t n)
{
    prepare(DrawMode::TRIANGLES);
    int triangles = n-2;
    int N = buffer_.size();
    buffer_.resize(N+3*triangles);
    auto p = &buffer_[N];
    auto const *q = points+1;
    auto const &color = getColor4();
    while(triangles-- > 0){
        p->pos = *points; p->color = color; p++;
        p->pos = *q++; p->color = color; p++;
        p->pos = *q++; p->color = color; p++;
    }
}
Exemplo n.º 6
0
void PrimitiveShader_PC::drawTriangleFan(const Mat3 &transform, const Vec2 *points, size_t n)
{
    prepare(DrawMode::TRIANGLES);
    int triangles = n-2;
    int N = buffer_.size();
    buffer_.resize(N+3*triangles);
    auto p = &buffer_[N];
    auto const *q = points+1;
    auto const &color = getColor4();
    auto p0 = Point{transform_helper(transform, *points), color};
    while(triangles-- > 0){
        *p++ = p0;
        *p++ = Point{transform_helper(transform, *q++), color};
        *p++ = Point{transform_helper(transform, *q++), color};
    }
}
Exemplo n.º 7
0
void PrimitiveShader_PC::drawLineStrip(const Vec2 *points, size_t n)
{
    prepare(DrawMode::LINES);
    int N = (int)buffer_.size();
    int lines = (n-1);
    buffer_.resize(N+2*lines);
    auto p = &buffer_[N];
    auto const & color = getColor4();
    for(int i=0; i<lines; i++){
        p->pos = *points;
        p->color = color;
        p++;
        p->pos = *++points;
        p->color = color;
        p++;
    }
}
Exemplo n.º 8
0
void PrimitiveShader_PC::drawRect(const Vec2 &bl, const Vec2 &size)
{
    prepare(DrawMode::TRIANGLES);
    int N = buffer_.size();
    buffer_.resize(N+6);
    auto p = &buffer_[N];
    p[0].pos = bl;
    p[1].pos = Vec2(bl.x+size.x, bl.y);
    p[2].pos = Vec2(bl.x+size.x, bl.y+size.y);
    p[3].pos = bl;
    p[4].pos = p[2].pos;
    p[5].pos = Vec2(bl.x, bl.y+size.y);
    auto const & c = getColor4();
    for(int i=0; i<6; i++){
        p->color = c; p++;
    }
}
void MultiColoredQuadUIDrawObject::draw(Graphics* const Graphics, Real32 Opacity) const
{
	Graphics->drawQuad(getPoint1(),getPoint2(),getPoint3(),getPoint4(),
                       getColor1(), getColor2(), getColor3(), getColor4(),
                       getOpacity()*Opacity);
}
Exemplo n.º 10
0
void PrimitiveShader_PC::drawLine(const Vec2 &p0, const Vec2 &p1)
{
    prepare(DrawMode::LINES);
    buffer_.push_back(Point{p0, getColor4()});
    buffer_.push_back(Point{p1, getColor4()});
}
Exemplo n.º 11
0
void PrimitiveShader_PC::drawLineLoop(const Mat3 &transform, const Vec2 *points, size_t n)
{
    drawLineStrip(transform, points, n);
    buffer_.push_back(Point{transform_helper(transform, points[n-1]),getColor4()});
    buffer_.push_back(Point{transform_helper(transform, *points),getColor4()});
}