rendering: use sprite batching techniques for rect primitives, unite their render path
This commit is contained in:
30
src/rendering/twn_quads.c
Normal file
30
src/rendering/twn_quads.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include "twn_draw_c.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
struct QuadBatch collect_quad_batch(const Primitive2D primitives[], size_t len) {
|
||||
if (primitives[0].type == PRIMITIVE_2D_SPRITE)
|
||||
return collect_sprite_batch(primitives, len);
|
||||
else if (primitives[0].type == PRIMITIVE_2D_RECT)
|
||||
return collect_rect_batch(primitives, len);
|
||||
else
|
||||
SDL_assert(false);
|
||||
|
||||
return (struct QuadBatch){0};
|
||||
}
|
||||
|
||||
|
||||
/* assumes that orthogonal matrix setup is done already */
|
||||
void render_quad_batch(const Primitive2D primitives[],
|
||||
const struct QuadBatch batch)
|
||||
{
|
||||
if (primitives[0].type == PRIMITIVE_2D_SPRITE)
|
||||
render_sprite_batch(primitives, batch);
|
||||
else if (primitives[0].type == PRIMITIVE_2D_RECT)
|
||||
render_rect_batch(primitives, batch);
|
||||
else
|
||||
SDL_assert(false);
|
||||
|
||||
return (struct QuadBatch){0};
|
||||
}
|
Reference in New Issue
Block a user