Skip to content

Commit

Permalink
Improve performance by removing canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
JayFoxRox committed Apr 15, 2020
1 parent 85d62c7 commit e20b9f1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ SDL_Rect gameTitleTagRect;
/* Current displayed bullet image */
SDL_Texture *gHandSurface = NULL;
/* block' surface */
SDL_Texture *canvas;
SDL_Texture * const canvas = NULL;
SDL_Texture *zombieLegs;
SDL_Texture *zombiePants;
SDL_Texture *zombieBody;
Expand Down Expand Up @@ -741,7 +741,7 @@ void loadMedia() {
font42 = TTF_OpenFont("assets/images/visitor1.ttf", 42);

createExtraBulletSprite(ENEMY_W * 4, ENEMY_H);
canvas = createEmptySprite(GAME_W, GAME_H);
SDL_SetRenderTarget(renderer, canvas);
}

void renderXCenteredText(TTF_Font *font, char string[], int y) {
Expand Down Expand Up @@ -1384,8 +1384,6 @@ void tick() {
}
}

SDL_SetRenderTarget(renderer, NULL);
SDL_RenderCopy(renderer, canvas, NULL, NULL);
SDL_RenderPresent(renderer);
}

Expand Down

0 comments on commit e20b9f1

Please sign in to comment.