summaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2019-01-13 19:00:35 +0100
committerSilvan Jegen <s.jegen@gmail.com>2019-01-13 19:00:35 +0100
commit4e3b66e4a82f7997ad9f1c2112e2af20728e406d (patch)
treeb96689f7e78f94adfd53c6285eee3c6e58d03a3f /render.c
parent92a4fbb74a151038391ddc03cb48e6b567776a0d (diff)
Use SDL_RenderCopy instead of SDL_UpdateTexture
Diffstat (limited to 'render.c')
-rw-r--r--render.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/render.c b/render.c
index 4e5db41..a713d5e 100644
--- a/render.c
+++ b/render.c
@@ -87,14 +87,33 @@ void render(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Textu
/// Draw this tile onto the screen
//SDL_BlitSurface ( currentlevel->surf_tiles, &pixmap_crop, surf_screen, &destination );
- // TODO: use pixmap_crop
+ // TODO: use pixmap_crop with SDL_RenderCopy?
// printf("surf_tile format: %s\n", SDL_GetPixelFormatName(currentlevel->surf_tiles->format->format));
- SDL_UpdateTexture(surf_screen, &destination,
- currentlevel->surf_tiles->pixels,
- currentlevel->surf_tiles->pitch);
+ // SDL_UpdateTexture(surf_screen, &destination,
+ // currentlevel->surf_tiles->pixels,
+ // currentlevel->surf_tiles->pitch);
+
+ printf("pixmap_crop x: %d, y: %d, w: %d, h: %d\n",
+ pixmap_crop.x, pixmap_crop.y, pixmap_crop.w, pixmap_crop.h);
+
+ printf("destination x: %d, y: %d, w: %d, h: %d\n",
+ destination.x, destination.y, destination.w, destination.h);
+
+ int ret = SDL_RenderCopy(renderer, currentlevel->surf_tiles_tex,
+ &pixmap_crop,
+ &destination);
+ printf("SDL_RenderCopy ret: %d\n", ret);
+ if (ret < 0 ) {
+ printf("Error (SDL): %s: %s\n", "could not render copy surf_tiles", SDL_GetError());
+ }
+
+ //printf("surf_tile pitch: %d\n", currentlevel->surf_tiles->pitch);
}
}
-
+
+ // SDL_RenderPresent(renderer);
+ // SDL_Delay(500);
+
/// Entity drawing
// First of all the character
get_pixmap_lemon( currentlevel->player_face, &pixmap_crop );
@@ -103,9 +122,13 @@ void render(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Textu
// Draw onto screen
//SDL_BlitSurface ( currentlevel->surf_entities, &pixmap_crop, surf_screen, &destination );
- SDL_UpdateTexture(surf_screen, &destination,
- currentlevel->surf_entities->pixels,
- currentlevel->surf_entities->pitch);
+ //SDL_UpdateTexture(surf_screen, &destination,
+ // currentlevel->surf_entities->pixels,
+ // currentlevel->surf_entities->pitch);
+
+ SDL_RenderCopy(renderer, currentlevel->surf_entities_tex,
+ &pixmap_crop,
+ &destination);
// Now draw all of the echidnas
int ech_no; // Echidna number
@@ -124,17 +147,21 @@ void render(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Textu
// Draw it onscreen
// SDL_BlitSurface ( currentlevel->surf_entities, &pixmap_crop, surf_screen, &destination );
- SDL_UpdateTexture(surf_screen, &destination,
- currentlevel->surf_entities->pixels,
- currentlevel->surf_entities->pitch);
+ // SDL_UpdateTexture(surf_screen, &destination,
+ // currentlevel->surf_entities->pixels,
+ // currentlevel->surf_entities->pitch);
+
+ SDL_RenderCopy(renderer, currentlevel->surf_entities_tex,
+ &pixmap_crop,
+ &destination);
}
}
/// Flip screen, so everything we have 'blitted' can now be seen
//SDL_Flip( surf_screen );
- SDL_RenderClear(renderer);
- SDL_RenderCopy(renderer, surf_screen, NULL, NULL);
+ //SDL_RenderClear(renderer);
+ //SDL_RenderCopy(renderer, surf_screen, NULL, NULL);
SDL_RenderPresent(renderer);
}