From fd53c7da8c5f2b79b87f624e313ff508072361ad Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 28 Jan 2024 03:01:13 +0100 Subject: Big rushed update --- src/instance/CMakeLists.txt | 2 +- src/instance/src/instance.c | 55 ++++++++------------------------------------- 2 files changed, 10 insertions(+), 47 deletions(-) (limited to 'src/instance') diff --git a/src/instance/CMakeLists.txt b/src/instance/CMakeLists.txt index 2e777a9..3651400 100644 --- a/src/instance/CMakeLists.txt +++ b/src/instance/CMakeLists.txt @@ -1,3 +1,3 @@ add_library(instance "src/instance.c") target_include_directories(instance PUBLIC "inc") -target_link_libraries(instance PUBLIC camera gfx util) +target_link_libraries(instance PUBLIC camera gfx util PRIVATE gui) diff --git a/src/instance/src/instance.c b/src/instance/src/instance.c index 1e9e039..91683f5 100644 --- a/src/instance/src/instance.c +++ b/src/instance/src/instance.c @@ -19,47 +19,18 @@ void instance_cyclic(void) line_g_flip ^= true; } -static int draw_sel(const struct instance *const i, const short x, const short y) -{ - enum {R = 0, G = 255, B = 0}; - - stp_4line_get_or_ret(l, -1); - stp_4line_init(l); - l->x = l->vertices[2].x = l->vertices[3].x = x; - l->y = l->vertices[0].y = l->vertices[3].y = y; - l->vertices[0].x = l->vertices[1].x = x + i->r.w; - l->vertices[1].y = l->vertices[2].y = y + i->r.h; - l->r = R; - l->g = line_g; - l->b = B >> 2; - - for (size_t i = 0; i < sizeof l->vertices / sizeof *l->vertices; i++) - { - struct stp_4line_vtx *const v = &l->vertices[i]; - - v->r = R; - v->b = B; - } - - l->vertices[0].g = l->vertices[2].g = UCHAR_MAX - line_g; - l->vertices[1].g = l->vertices[3].g = line_g; - stp_4line_sort(l); - stp_4line_get_or_ret(ll, -1); - *ll = *l; - ll->x = ll->vertices[2].x = ll->vertices[3].x = l->x ? l->x - 1 : 0; - ll->y = ll->vertices[0].y = ll->vertices[3].y = l->y ? l->y - 1 : 0; - ll->vertices[0].x = ll->vertices[1].x = l->vertices[0].x + 1; - ll->vertices[1].y = ll->vertices[2].y = l->vertices[1].y + 1; - stp_4line_sort(ll); - return 0; -} - -static void render_sprite(struct sprite *const s, +static int render_sprite(struct sprite *const s, const struct instance_render_off *const off, const short x, const short y) { s->x = off ? x + off->x : x; s->y = off ? y + off->y : y; - sprite_sort(s); + + const int ret = sprite_sort(s); + + if (ret) + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + + return ret; } static void render_quad(const struct instance_render_quad *const rq, @@ -99,9 +70,6 @@ int instance_render(const struct instance_render_cfg *const cfg) { const struct instance_render_off *const off = cfg->off; - if (cfg->sel && draw_sel(i, x, y)) - return -1; - switch (cfg->prim_type) { case INSTANCE_RENDER_CFG_SPRITE: @@ -120,10 +88,5 @@ int instance_render(const struct instance_render_cfg *const cfg) int instance_render_target(const struct instance *const i, const struct camera *const cam) { - short x, y; - - if (camera_translate(cam, &i->r, &x, &y)) - return draw_sel(i, x, y); - - return -1; + return 0; } -- cgit v1.2.3