0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 10:13:42 +00:00
SDL_Minigame/include/TextureManager.h

31 lines
867 B
C++

#pragma once
#include "ECS.h"
#include "SDL3/SDL_surface.h"
#include <SDL3/SDL_render.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
class TextureManager
{
public:
TextureManager(Manager* manager) : manager(manager) {}
~TextureManager() {
for (auto& it : this->texture_cache) {
SDL_DestroyTexture(it.second);
}
}
std::map<std::string, SDL_Texture*> texture_cache;
SDL_Texture* loadTexture(const char* fileName);
static std::vector<SDL_Rect> splitSpriteSheet(SDL_Texture* spriteSheet, int width, int height, int spritesOnSheet);
static void draw(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect src, SDL_FRect dest, bool flipped = false);
void setScaleMode(SDL_ScaleMode scaleMode) { this->scaleMode = scaleMode; }
private:
SDL_ScaleMode scaleMode = SDL_SCALEMODE_NEAREST;
Manager* manager;
};