36 lines
772 B
C++
36 lines
772 B
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_init.h>
|
|
#include <SDL3_ttf/SDL_textengine.h>
|
|
#include <SDL3_ttf/SDL_ttf.h>
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include "fileCommon.h"
|
|
#include "window.h"
|
|
|
|
#define WHITE {255, 255, 255, SDL_ALPHA_OPAQUE}
|
|
|
|
|
|
class Text {
|
|
|
|
private:
|
|
std::string buffer;
|
|
TTF_Font *loadedFont = nullptr;
|
|
|
|
SDL_Surface *textRenderingSurface = nullptr;
|
|
SDL_Color color = {};
|
|
|
|
SDL_Texture *font_texture = nullptr;
|
|
|
|
/// ToDo: Replace with dynamic settings / loaded font
|
|
fs::path fontPath;
|
|
|
|
|
|
public:
|
|
SDL_AppResult OpenFont(const fs::path &font);
|
|
bool SetText(const std::string &text, const Window *win, SDL_FRect rect);
|
|
void Render() const;
|
|
void CloseFont() const { TTF_CloseFont(loadedFont); }
|
|
};
|