From 103b5c0eea22b6570ada8ae9200ab069466bd1b3 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 24 Mar 2021 10:07:47 -0400 Subject: map: Copy the tileset texture to the layer texture Not the layer texture to the layer texture. That's just stupid. --- (limited to 'src/map.c') diff --git a/src/map.c b/src/map.c index 7eb789b..40c93a2 100644 --- a/src/map.c +++ b/src/map.c @@ -507,7 +507,7 @@ _db_tmx_map_start(void *pv, const char *name, const char **attr) static int _db_map_render_layer(struct db_map *map, struct db_map_layer *layer, - SDL_Renderer *renderer, SDL_Texture *texture) + SDL_Renderer *renderer) { int i; int gid; @@ -553,8 +553,11 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer, tile_rect.w, tile_rect.h, tile_rect.x, tile_rect.y, layer_rect.x, layer_rect.y); - if (SDL_RenderCopy(renderer, texture, - &tile_rect, &layer_rect) != 0) { + if (SDL_RenderCopy(renderer, db_tileset_texture( + tileset, + renderer), + &tile_rect, &layer_rect) + != 0) { db_err("Failed to copy texture (%s)", SDL_GetError()); return -1; @@ -574,16 +577,10 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer, SDL_Texture * db_map_render(struct db_map *map, SDL_Renderer *renderer) { - struct db_tileset *tileset; SDL_Texture *texture; SDL_Texture *old_target; struct db_map_layer *layer; - for (tileset = map->tileset_head; tileset != NULL; - tileset = db_tileset_next(tileset)) { - db_tileset_create_texture(tileset, renderer); - } - texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, map->w, map->h); old_target = SDL_GetRenderTarget(renderer); @@ -594,7 +591,7 @@ db_map_render(struct db_map *map, SDL_Renderer *renderer) } for (layer = map->layer_head; layer != NULL; layer = layer->next) { - if (_db_map_render_layer(map, layer, renderer, texture) != 0) { + if (_db_map_render_layer(map, layer, renderer) != 0) { return NULL; } } -- cgit v0.9.1