summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 42baa75..6b195b4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -151,6 +151,8 @@ int main(int const argc, char *const *const argv) {
}
SDL_RenderSetLogicalSize(renderer, WINDOW_WIDTH, WINDOW_HEIGHT);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
+
+ SDL_Texture *framebuffer = SDL_CreateTexture(renderer, SDL_PIXELTYPE_UNKNOWN, SDL_TEXTUREACCESS_TARGET, WINDOW_WIDTH, WINDOW_HEIGHT);
{
res_init();
@@ -297,9 +299,6 @@ int main(int const argc, char *const *const argv) {
fprintf(stderr, "unknown event type %i\n", evt.type);
}
}
- SDL_SetRenderTarget(renderer, NULL);
- SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
- SDL_RenderClear(renderer);
//SDL_RenderCopy(renderer, tilemap->wang_tileset, &(SDL_Rect) {0, 0, 128, 90}, &(SDL_Rect) {0, 0, 128, 90});
if (player[0].update(player)) {
@@ -313,10 +312,15 @@ int main(int const argc, char *const *const argv) {
if (x < 0) {x = 0;} else if (x + WINDOW_WIDTH > tilemap->width * 8) {x = tilemap->width * 8 - WINDOW_WIDTH;}
if (y < 0) {y = 0;} else if (y + WINDOW_HEIGHT > tilemap->height * 8) {y = tilemap->height * 8 - WINDOW_HEIGHT;}
+ SDL_SetRenderTarget(renderer, framebuffer);
tilemap_background(tilemap, x, y, WINDOW_WIDTH, WINDOW_HEIGHT);
player[0].draw(player, x, y);
tilemap_foreground(tilemap, x, y, WINDOW_WIDTH, WINDOW_HEIGHT);
//SDL_RenderCopy(renderer, res_get_texture("meow").data, &(SDL_Rect) {0, 0, 128, 90}, &(SDL_Rect) {0, 0, 128, 90});
+ SDL_SetRenderTarget(renderer, NULL);
+ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
+ SDL_RenderClear(renderer);
+ SDL_RenderCopy(renderer, framebuffer, &(SDL_Rect) {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}, &(SDL_Rect) {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT});
// then we wait for the next video frame
SDL_RenderPresent(renderer);
}