Files
letnik3koncni-prap/include/renderer/font.hpp
2026-05-19 22:35:10 +02:00

32 lines
1.0 KiB
C++

#pragma once
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <utils.hpp>
#include <string>
#include <renderer/texture.hpp>
namespace Game::Renderer {
class Font : public Texture {
public:
Font(const std::string& path, SDL_Renderer* renderer, int ptSize, std::string id = "noname");
Font(const Font&);
Font& operator=(const Font&);
DISABLE_MOVE(Font);
~Font();
// Build the texture for the font; Call getSDLTexture() afterwards
void build(SDL_Color color, std::string text);
// Rebuild GPU-backed texture after a renderer/device reset
bool reload(SDL_Renderer* renderer);
SDL_Texture* getSDLTexture();
std::string getId();
private:
TTF_Font* mFont;
SDL_Renderer* mRenderer;
// Remember last build params so we can rebuild fonts on device reset
std::string mLastText;
SDL_Color mLastColor;
};
}