Support drawing multi-color triangles in gfx::painter
This commit is contained in:
parent
ed41bc6583
commit
ebda20ff9c
2 changed files with 9 additions and 3 deletions
|
|
@ -53,6 +53,7 @@ namespace psemek::gfx
|
|||
|
||||
// 2D
|
||||
void triangle(geom::point<float, 2> const & p0, geom::point<float, 2> const & p1, geom::point<float, 2> const & p2, color const & c);
|
||||
void triangle(geom::point<float, 2> const & p0, geom::point<float, 2> const & p1, geom::point<float, 2> const & p2, color const & c0, color const & c1, color const & c2);
|
||||
void rect(geom::box<float, 2> const & box, color const & c);
|
||||
void circle(geom::point<float, 2> const & center, float radius, color const & c, int quality = 24);
|
||||
void line(geom::point<float, 2> const & p0, geom::point<float, 2> const & p1, float width, color const & c, bool smooth = true);
|
||||
|
|
|
|||
|
|
@ -184,12 +184,17 @@ namespace psemek::gfx
|
|||
painter::~painter() = default;
|
||||
|
||||
void painter::triangle(geom::point<float, 2> const & p0, geom::point<float, 2> const & p1, geom::point<float, 2> const & p2, color const & c)
|
||||
{
|
||||
triangle(p0, p1, p2, c, c, c);
|
||||
}
|
||||
|
||||
void painter::triangle(geom::point<float, 2> const & p0, geom::point<float, 2> const & p1, geom::point<float, 2> const & p2, color const & c0, color const & c1, color const & c2)
|
||||
{
|
||||
std::uint32_t const base = impl().vertices.size();
|
||||
|
||||
impl().vertices.push_back({{p0[0], p0[1], 0.f}, c});
|
||||
impl().vertices.push_back({{p1[0], p1[1], 0.f}, c});
|
||||
impl().vertices.push_back({{p2[0], p2[1], 0.f}, c});
|
||||
impl().vertices.push_back({{p0[0], p0[1], 0.f}, c0});
|
||||
impl().vertices.push_back({{p1[0], p1[1], 0.f}, c1});
|
||||
impl().vertices.push_back({{p2[0], p2[1], 0.f}, c2});
|
||||
|
||||
impl().indices.push_back(base + 0);
|
||||
impl().indices.push_back(base + 1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue