diff options
Diffstat (limited to 'src/sdl/draw.c')
-rw-r--r-- | src/sdl/draw.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/sdl/draw.c b/src/sdl/draw.c index bf73129..ab4803e 100644 --- a/src/sdl/draw.c +++ b/src/sdl/draw.c @@ -4,7 +4,7 @@ #include "draw.h" #include "sprites.h" -#undef DRAW_SPRITES +#define DRAW_SPRITES static size_t get_cell_size( @@ -34,30 +34,20 @@ draw_cell( const sok_pos_t pos, const sprite_t sprite ) { - const SDL_Rect dst_rect = get_cell_rect(draw_ctx, pos); + const SDL_Rect rect = get_cell_rect(draw_ctx, pos); #ifdef DRAW_SPRITES - const SDL_Rect src_rect = sprites_get_rect(sprite); - -#if 0 - SDL_Log( - "src_rect = { %d, %d, %d, %d }, dst_rect = { %d, %d, %d, %d }", - src_rect.x, src_rect.y, src_rect.w, src_rect.h, - dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h - ); -#endif /* 0 */ - - if (SDL_RenderCopy(draw_ctx->renderer, draw_ctx->sprites, &src_rect, &dst_rect)) { + SDL_Texture *tex = draw_ctx->sprites[sprite]; + if (SDL_RenderCopy(draw_ctx->renderer, tex, NULL, &rect)) { die("SDL_RenderCopy(): %s", SDL_GetError()); } #else - if (SDL_RenderFillRect(draw_ctx->renderer, &dst_rect)) { + if (SDL_RenderFillRect(draw_ctx->renderer, &rect)) { die("SDL_RenderFillRect(): %s", SDL_GetError()); } #endif /* DRAW_SPRITES */ } - static bool draw_on_size( const sok_ctx_t * const ctx, @@ -189,7 +179,6 @@ draw( // render sok_ctx_walk(draw_ctx->ctx, &DRAW_CBS, draw_ctx); - // flip + // flip SDL_RenderPresent(draw_ctx->renderer); } - |