twn_draw.c: add draw_quad()
This commit is contained in:
@ -179,6 +179,31 @@ void draw_nine_slice(const char *texture, Vec2 corners, Rect rect, float border_
|
||||
}
|
||||
|
||||
|
||||
TWN_API void draw_quad(char const *texture,
|
||||
Vec3 v0, /* upper-left */
|
||||
Vec3 v1, /* bottom-left */
|
||||
Vec3 v2, /* bottom-right */
|
||||
Vec3 v3, /* upper-right */
|
||||
Rect texture_region,
|
||||
Color color)
|
||||
{
|
||||
Vec2 const uv0 = { texture_region.x, texture_region.y };
|
||||
Vec2 const uv1 = { texture_region.x, texture_region.y + texture_region.h };
|
||||
Vec2 const uv2 = { texture_region.x + texture_region.w, texture_region.y + texture_region.h };
|
||||
Vec2 const uv3 = { texture_region.x + texture_region.w, texture_region.y };
|
||||
|
||||
draw_triangle(texture,
|
||||
v0, v1, v3,
|
||||
uv0, uv1, uv3,
|
||||
color, color, color);
|
||||
|
||||
draw_triangle(texture,
|
||||
v3, v1, v2,
|
||||
uv3, uv1, uv2,
|
||||
color, color, color);
|
||||
}
|
||||
|
||||
|
||||
static void render_2d(void) {
|
||||
use_2d_pipeline();
|
||||
|
||||
|
Reference in New Issue
Block a user