summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/map.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/map.c b/src/map.c
index 53dd570..7eb789b 100644
--- a/src/map.c
+++ b/src/map.c
@@ -505,7 +505,7 @@ _db_tmx_map_start(void *pv, const char *name, const char **attr)
}
}
-static void
+static int
_db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
SDL_Renderer *renderer, SDL_Texture *texture)
{
@@ -553,8 +553,12 @@ _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);
- SDL_RenderCopy(renderer, texture,
- &tile_rect, &layer_rect);
+ if (SDL_RenderCopy(renderer, texture,
+ &tile_rect, &layer_rect) != 0) {
+ db_err("Failed to copy texture (%s)",
+ SDL_GetError());
+ return -1;
+ }
tile_found = SDL_TRUE;
break;
}
@@ -563,6 +567,8 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
db_warn("Tile with gid 0x%8.8x not found", gid);
}
}
+
+ return 0;
}
SDL_Texture *
@@ -582,9 +588,15 @@ db_map_render(struct db_map *map, SDL_Renderer *renderer)
SDL_TEXTUREACCESS_TARGET, map->w, map->h);
old_target = SDL_GetRenderTarget(renderer);
SDL_SetRenderTarget(renderer, texture);
+ if (SDL_RenderClear(renderer) != 0) {
+ db_err("Failed to clear texture (%s)", SDL_GetError());
+ return NULL;
+ }
for (layer = map->layer_head; layer != NULL; layer = layer->next) {
- _db_map_render_layer(map, layer, renderer, texture);
+ if (_db_map_render_layer(map, layer, renderer, texture) != 0) {
+ return NULL;
+ }
}
SDL_SetRenderTarget(renderer, old_target);