From 4e3b66e4a82f7997ad9f1c2112e2af20728e406d Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Sun, 13 Jan 2019 19:00:35 +0100 Subject: Use SDL_RenderCopy instead of SDL_UpdateTexture --- level.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'level.c') diff --git a/level.c b/level.c index 6097f23..b00e235 100644 --- a/level.c +++ b/level.c @@ -67,7 +67,9 @@ struct level_struct // Resources SDL_Surface * surf_entities; // Player and echidna pictures + SDL_Texture * surf_entities_tex; SDL_Surface * surf_tiles; // Level tiles/squares + SDL_Texture * surf_tiles_tex; // A various selection of losing screens SDL_Surface * surf_losingscreens[5]; @@ -77,7 +79,6 @@ struct level_struct // Up to ten echidnas struct echidna echidnas[10]; - }; @@ -106,10 +107,20 @@ void level_load_resources(SDL_Renderer* renderer, struct level_struct *level ) level->surf_entities = SDL_ConvertSurfaceFormat(surf_entities, SDL_PIXELFORMAT_ARGB8888, 0); + level->surf_entities_tex = SDL_CreateTextureFromSurface(renderer, + level->surf_entities); + SDL_Surface* surf_tiles = IMG_Load( "tiles.png" ); level->surf_tiles = SDL_ConvertSurfaceFormat(surf_tiles, SDL_PIXELFORMAT_ARGB8888, 0); + + level->surf_tiles_tex = SDL_CreateTextureFromSurface(renderer, + level->surf_tiles); + int w, h; + Uint32 format; + SDL_QueryTexture(level->surf_tiles_tex, &format, NULL, &w, &h); + printf("surf_tiles_tex: w: %d, h: %d, format: %s\n", w, h, SDL_GetPixelFormatName(format)); // Do the same for the losing screens SDL_Surface* surf_losing = IMG_Load("failscreen_01.png"); -- cgit v1.2.1-18-gbd029