예제 #1
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};
    }
}
예제 #2
0
void PrimitiveShader_PC::drawTriangleFan(const Mat3 &transform, const Point *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 p0 = Point{transform_helper(transform,points->pos), points->color};
    while(triangles-- > 0){
        *p++ = p0;
        *p++ = Point{transform_helper(transform, q->pos), q->color};q++;
        *p++ = Point{transform_helper(transform, q->pos), q->color};q++;
    }
}
예제 #3
0
 static constexpr decltype(auto) apply(Xs&& xs, F&& f) {
     using Raw = typename detail::std::remove_reference<Xs>::type;
     constexpr auto N = ::std::tuple_size<Raw>::value;
     return transform_helper(
         detail::std::forward<Xs>(xs),
         detail::std::forward<F>(f),
         detail::std::make_index_sequence<N>{}
     );
 }
예제 #4
0
void PrimitiveShader_PC::pushPoints(const Mat3 &transform, const Vec2 *points, size_t n, const Color4 &color)
{
    int N = (int)buffer_.size();
    buffer_.resize(N+n);
    auto p = &buffer_[N];
    for(int i=0; i<n; i++){
        *p++ = Point{transform_helper(transform, *points++), color};
    }
}
예제 #5
0
void PrimitiveShader_PC::pushPoints(const Mat3 &transform, const Point *points, size_t n)
{
    int N = (int)buffer_.size();
    buffer_.resize(N+n);
    auto p = &buffer_[N];
    for(int i=0; i<n; i++){
        *p++ = Point{transform_helper(transform, points->pos), points->color};
        points++;
    }
}
예제 #6
0
void PrimitiveShader_PC::drawLineLoop(const Mat3 &transform, const Point *points, size_t n)
{
    drawLineStrip(transform, points, n);
    buffer_.push_back(Point{transform_helper(transform, points[n-1].pos),points[n-1].color});
    buffer_.push_back(Point{transform_helper(transform, points[0].pos),points->color});
}
예제 #7
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()});
}