Added Text.cpp
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#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(fs::path fontPath);
|
||||
bool SetText(std::string text, Window *window);
|
||||
void Render();
|
||||
void CloseFont() { TTF_CloseFont(loadedFont); }
|
||||
};
|
||||
Reference in New Issue
Block a user