From 535d5d8d36782be339998f7018b681c3246980e8 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Mon, 23 Sep 2024 09:50:01 +0300 Subject: [PATCH] twn_textures.c: little pieces --- src/twn_textures.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/twn_textures.c b/src/twn_textures.c index 270bf77..626d909 100644 --- a/src/twn_textures.c +++ b/src/twn_textures.c @@ -344,7 +344,7 @@ static t_texture_key textures_load(struct texture_cache *cache, const char *path /* it's a "loner texture," it doesn't fit in an atlas so it's not in one */ if (surface->w >= TEXTURE_ATLAS_SIZE || surface->h >= TEXTURE_ATLAS_SIZE) { if (ctx.game.debug) { - if (surface->w > TEXTURE_ATLAS_SIZE || surface->h > TEXTURE_ATLAS_SIZE) + if (surface->w > 2048 || surface->h > 2048) log_warn("Unportable texture dimensions for %s, use 2048x2048 at max", path); if (!is_power_of_two(surface->w) || !is_power_of_two(surface->h)) log_warn("Unportable texture dimensions for %s, should be powers of 2", path); @@ -352,14 +352,13 @@ static t_texture_key textures_load(struct texture_cache *cache, const char *path new_texture.loner_texture = create_gpu_texture(TEXTURE_FILTER_NEAREAST, true); upload_texture_from_surface(new_texture.loner_texture, surface); new_texture.srcrect = (t_frect) { .w = (float)surface->w, .h = (float)surface->h }; - shput(cache->hash, path, new_texture); - return (t_texture_key){ (uint16_t)shgeti(cache->hash, path) }; } else { + /* will be fully populated as the atlas updates */ new_texture.atlas_index = cache->atlas_index; - shput(cache->hash, path, new_texture); cache->is_dirty = true; - return (t_texture_key){ (uint16_t)shgeti(cache->hash, path) }; } + shput(cache->hash, path, new_texture); + return (t_texture_key){ (uint16_t)shgeti(cache->hash, path) }; } @@ -544,6 +543,8 @@ void textures_bind_repeating(const struct texture_cache *cache, t_texture_key ke cache->hash[key.id].value.repeating_texture = repeating_texture; + bind_gpu_texture(repeating_texture); + } else bind_gpu_texture(cache->hash[key.id].value.loner_texture);