#include "Helper.h" void drawTexture(SDL_Renderer *renderer, SDL_Texture *texture, int x, int y, int w, int h) { SDL_Rect src; src.x = 0; src.y = 0; SDL_QueryTexture(texture, nullptr, nullptr, &src.w, &src.h); SDL_Rect dist; dist.x = x; dist.y = y; dist.w = w; dist.h = h; SDL_RenderCopy(renderer, texture, &src, &dist); } void drawText(SDL_Renderer *renderer, TTF_Font *font, const std::string text, int x, int y, int w, int h) { SDL_Surface *surface = TTF_RenderText_Solid(font, text.c_str(), {255, 255, 255}); SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_Rect src; src.x = 0; src.y = 0; SDL_QueryTexture(texture, nullptr, nullptr, &src.w, &src.h); SDL_Rect dist; dist.x = x; dist.y = y; dist.w = w; dist.h = h; SDL_RenderCopy(renderer, texture, &src, &dist); SDL_FreeSurface(surface); SDL_DestroyTexture(texture); }