twn_textures.c: fix srcrect setting on atlas rebuild
This commit is contained in:
@ -130,8 +130,8 @@ static void upload_texture_from_surface(gpu_texture texture, SDL_Surface *surfac
|
||||
|
||||
|
||||
static void recreate_current_atlas_texture(struct texture_cache *cache) {
|
||||
/* TODO: figure out if SDL_UpdateTexture alone is faster than blitting */
|
||||
/* TODO: should surfaces be freed after they cannot be referenced in atlas builing? */
|
||||
/* for example, if full page of 64x64 tiles was already filled, there's no real reason to process them further */
|
||||
SDL_Surface *atlas_surface = cache->atlas_surfaces[cache->atlas_index];
|
||||
|
||||
/* clear */
|
||||
@ -230,13 +230,19 @@ static bool update_rects(struct texture_cache *cache, stbrp_rect *rects, stbrp_r
|
||||
|
||||
/* updates the atlas location of every rect in the cache */
|
||||
static void update_texture_rects_in_atlas(struct texture_cache *cache, stbrp_rect *rects) {
|
||||
int r = 0;
|
||||
for (size_t i = 0; i < arrlenu(rects); ++i) {
|
||||
if (cache->hash[i].value.loner_texture != 0)
|
||||
continue;
|
||||
|
||||
cache->hash[i].value.srcrect = (t_frect) {
|
||||
.x = (float)rects[i].x,
|
||||
.y = (float)rects[i].y,
|
||||
.w = (float)rects[i].w,
|
||||
.h = (float)rects[i].h,
|
||||
.x = (float)rects[r].x,
|
||||
.y = (float)rects[r].y,
|
||||
.w = (float)rects[r].w,
|
||||
.h = (float)rects[r].h,
|
||||
};
|
||||
|
||||
r++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user