Skip to content

Commit

Permalink
move renderttf comments to renderttf.h for #199
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Oct 24, 2022
1 parent 1f26120 commit 186d1c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/engine/render/renderttf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ bool TTFRenderer::initttf()
return true;
}

//opens a font with the given path and size in points
//if fails, returns nullptr to internal value f
void TTFRenderer::openfont(const char * inpath, int size)
{
f = TTF_OpenFont(inpath, size);
Expand All @@ -45,8 +43,6 @@ void TTFRenderer::openfont(const char * inpath, int size)
path = inpath;
}

//draws a string to the coordinates x, y in the current hud context at a scale factor `scale`
//with a (BGRA) SDL_Color value as passed to its third parameter
void TTFRenderer::renderttf(const char* message, SDL_Color col, int x, int y, float scale, uint wrap)
{
std::string msg = std::string(message);
Expand Down Expand Up @@ -93,7 +89,6 @@ void TTFRenderer::renderttf(const char* message, SDL_Color col, int x, int y, fl
}
}

//returns an object containing a GLuint and its dimensions refering to a rectangle texture containing the rendered image of a texture
TTFRenderer::TTFSurface TTFRenderer::renderttfgl(const char* message, SDL_Color col, int x, int y, float scale, uint wrap)
{
if(!message)
Expand All @@ -116,8 +111,6 @@ TTFRenderer::TTFSurface TTFRenderer::renderttfgl(const char* message, SDL_Color
return tts;
}

//sets the current working font renderer to one with the appropriate font size
//if the size does not exist already, creates a new one with the appropriate size
void TTFRenderer::fontsize(int pts)
{
auto itr = fontcache.find(pts);
Expand Down
9 changes: 9 additions & 0 deletions src/engine/render/renderttf.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ class TTFRenderer
};

bool initttf();

//opens a font with the given path and size in points
//if fails, returns nullptr to internal value f
void openfont(const char * path, int size);

//draws a string to the coordinates x, y in the current hud context at a scale factor `scale`
//with a (BGRA) SDL_Color value as passed to its third parameter
void renderttf(const char* message, SDL_Color col, int x, int y, float scale = 1.f, uint wrap = 0);

//sets the current working font renderer to one with the appropriate font size
//if the size does not exist already, creates a new one with the appropriate size
void fontsize(int pts = 12);
private:
TTF_Font* f; //the current working font
Expand Down

0 comments on commit 186d1c3

Please sign in to comment.