--- a/src/texture.c Sun May 11 14:51:00 2025 +0200 +++ b/src/texture.c Mon May 12 20:51:57 2025 +0200 @@ -162,3 +162,16 @@ } glDeleteTextures(count, textures); } + +asc_vec2f asc_texture_calculate_uv_scale(const AscTexture *tex, asc_vec2u surface_dimension, asc_vec2f factors) { + if (surface_dimension.width == 0 || surface_dimension.height == 0) { + asc_wprintf("Tried to calculate UV scale for texture %u with zero dimensions.", tex->tex_id); + return factors; + } + asc_vec2f uv_scale = factors; + uv_scale.u *= (float) tex->width; + uv_scale.u /= (float) surface_dimension.width; + uv_scale.v *= (float) tex->height; + uv_scale.v /= (float) surface_dimension.height; + return uv_scale; +}