void render::triangle(Vector2D a, Vector2D b, Vector2D c, Color col)
{
if (!m_surface())
return;
col.SetAlpha(static_cast<int>(col.a() * alpha_factor));
auto s = m_surface();
static int texture = surface->CreateNewTextureID(true);
s->DrawSetColor(color);
s->DrawSetTexture(texture);
s->DrawLine(a.x, a.y, b.x, b.y);
s->DrawLine(b.x, b.y, c.x, c.y);
s->DrawLine(c.x, c.y, a.x, a.y);
}
void render::triangle_filled(Vector2D a, Vector2D b, Vector2D c, Color col)
{
if (!m_surface())
return;
col.SetAlpha(static_cast<int>(col.a() * alpha_factor));
Vertex_t verts[3] = {
Vertex_t(a),
Vertex_t(b),
Vertex_t(c)
};
auto surface = m_surface();
static int texture = surface->CreateNewTextureID(true);
unsigned char buffer[4] = { 255, 255, 255, 255 };
surface->DrawSetTextureRGBA(texture, buffer, 1, 1);
surface->DrawSetColor(col);
surface->DrawSetTexture(texture);
surface->DrawTexturedPolygon(3, verts);
}