rendering: use sprite batching techniques for rect primitives, unite their render path
This commit is contained in:
@ -35,22 +35,6 @@ void render_queue_clear(void) {
|
||||
}
|
||||
|
||||
|
||||
/* rectangle */
|
||||
void draw_rectangle(Rect rect, Color color) {
|
||||
RectPrimitive rectangle = {
|
||||
.rect = rect,
|
||||
.color = color,
|
||||
};
|
||||
|
||||
Primitive2D primitive = {
|
||||
.type = PRIMITIVE_2D_RECT,
|
||||
.rect = rectangle,
|
||||
};
|
||||
|
||||
arrput(ctx.render_queue_2d, primitive);
|
||||
}
|
||||
|
||||
|
||||
void draw_9slice(const char *texture_path, int texture_w, int texture_h, int border_thickness, Rect rect, Color color) {
|
||||
const float bt = (float)border_thickness; /* i know! */
|
||||
const float bt2 = bt * 2; /* combined size of the two borders in an axis */
|
||||
@ -204,19 +188,27 @@ static void render_2d(void) {
|
||||
|
||||
switch (current->type) {
|
||||
case PRIMITIVE_2D_SPRITE: {
|
||||
const struct SpriteBatch batch =
|
||||
const struct QuadBatch batch =
|
||||
collect_sprite_batch(current, render_queue_len - i);
|
||||
|
||||
/* TODO: what's even the point? just use OR_EQUAL comparison */
|
||||
set_depth_range((double)batch_count / UINT16_MAX, 1.0);
|
||||
render_sprites(current, batch);
|
||||
render_sprite_batch(current, batch);
|
||||
|
||||
i += batch.size - 1; ++batch_count;
|
||||
break;
|
||||
}
|
||||
case PRIMITIVE_2D_RECT:
|
||||
render_rectangle(¤t->rect);
|
||||
case PRIMITIVE_2D_RECT: {
|
||||
const struct QuadBatch batch =
|
||||
collect_rect_batch(current, render_queue_len - i);
|
||||
|
||||
/* TODO: what's even the point? just use OR_EQUAL comparison */
|
||||
set_depth_range((double)batch_count / UINT16_MAX, 1.0);
|
||||
render_rect_batch(current, batch);
|
||||
|
||||
i += batch.size - 1; ++batch_count;
|
||||
break;
|
||||
}
|
||||
case PRIMITIVE_2D_CIRCLE:
|
||||
render_circle(¤t->circle);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user