diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-28 03:01:13 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-28 15:17:49 +0100 |
| commit | fd53c7da8c5f2b79b87f624e313ff508072361ad (patch) | |
| tree | db569413cd3d42034a22368a7980aa99d7d55235 /src/instance | |
| parent | e49e3073c67af785447ddb0ecbdc521b68cf3ea9 (diff) | |
Big rushed update
Diffstat (limited to 'src/instance')
| -rw-r--r-- | src/instance/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/instance/src/instance.c | 55 |
2 files changed, 10 insertions, 47 deletions
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; } |
