mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 14:34:34 +00:00
BmpFont usage is now a ref instead of a ptr, const-ify glfont
This commit is contained in:
parent
69ae4bdb20
commit
4e632f9f6c
16 changed files with 99 additions and 98 deletions
|
@ -151,45 +151,45 @@ void GLFont::Destroy (void)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::GetTexSize (std::pair<int, int> *size)
|
||||
void GLFont::GetTexSize (std::pair<int, int> *size) const
|
||||
{
|
||||
//Retrieve texture size
|
||||
size->first = header.tex_width;
|
||||
size->second = header.tex_height;
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetTexWidth (void)
|
||||
int GLFont::GetTexWidth (void) const
|
||||
{
|
||||
//Return texture width
|
||||
return header.tex_width;
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetTexHeight (void)
|
||||
int GLFont::GetTexHeight (void) const
|
||||
{
|
||||
//Return texture height
|
||||
return header.tex_height;
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::GetCharInterval (std::pair<int, int> *interval)
|
||||
void GLFont::GetCharInterval (std::pair<int, int> *interval) const
|
||||
{
|
||||
//Retrieve character interval
|
||||
interval->first = header.start_char;
|
||||
interval->second = header.end_char;
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetStartChar (void)
|
||||
int GLFont::GetStartChar (void) const
|
||||
{
|
||||
//Return start character
|
||||
return header.start_char;
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetEndChar (void)
|
||||
int GLFont::GetEndChar (void) const
|
||||
{
|
||||
//Return end character
|
||||
return header.end_char;
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::GetCharSize (unsigned char c, std::pair<int, int> *size)
|
||||
void GLFont::GetCharSize (unsigned char c, std::pair<int, int> *size) const
|
||||
{
|
||||
//Make sure character is in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -210,7 +210,7 @@ void GLFont::GetCharSize (unsigned char c, std::pair<int, int> *size)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetCharWidth (unsigned char c)
|
||||
int GLFont::GetCharWidth (unsigned char c) const
|
||||
{
|
||||
//Make sure in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -234,7 +234,7 @@ int GLFont::GetCharWidth (unsigned char c)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetCharHeight (unsigned char c)
|
||||
int GLFont::GetCharHeight (unsigned char c) const
|
||||
{
|
||||
//Make sure in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -249,13 +249,13 @@ int GLFont::GetCharHeight (unsigned char c)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::Begin (void)
|
||||
void GLFont::Begin (void) const
|
||||
{
|
||||
//Bind to font texture
|
||||
glBindTexture(GL_TEXTURE_2D, header.tex);
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::GetStringSize (const std::string &text, std::pair<int, int> *size)
|
||||
void GLFont::GetStringSize (const std::string &text, std::pair<int, int> *size) const
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int c;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//glFont namespace
|
||||
namespace glfont
|
||||
{
|
||||
class GLFont;
|
||||
class GLFont;
|
||||
}
|
||||
|
||||
//glFont class
|
||||
|
@ -60,38 +60,38 @@ public:
|
|||
void Destroy (void);
|
||||
|
||||
//Texture size retrieval methods
|
||||
void GetTexSize (std::pair<int, int> *size);
|
||||
int GetTexWidth (void);
|
||||
int GetTexHeight (void);
|
||||
void GetTexSize (std::pair<int, int> *size) const;
|
||||
int GetTexWidth (void) const;
|
||||
int GetTexHeight (void) const;
|
||||
|
||||
//Character interval retrieval methods
|
||||
void GetCharInterval (std::pair<int, int> *interval);
|
||||
int GetStartChar (void);
|
||||
int GetEndChar (void);
|
||||
void GetCharInterval (std::pair<int, int> *interval) const;
|
||||
int GetStartChar (void) const;
|
||||
int GetEndChar (void) const;
|
||||
|
||||
//Character size retrieval methods
|
||||
void GetCharSize (unsigned char c, std::pair<int, int> *size);
|
||||
int GetCharWidth (unsigned char c);
|
||||
int GetCharHeight (unsigned char c);
|
||||
|
||||
void GetStringSize (const std::string &text, std::pair<int, int> *size);
|
||||
void GetCharSize (unsigned char c, std::pair<int, int> *size) const;
|
||||
int GetCharWidth (unsigned char c) const;
|
||||
int GetCharHeight (unsigned char c) const;
|
||||
|
||||
void GetStringSize (const std::string &text, std::pair<int, int> *size) const;
|
||||
|
||||
|
||||
//Begins text output with this font
|
||||
void Begin (void);
|
||||
|
||||
void Begin (void) const;
|
||||
|
||||
//Template function to output a scaled, colored std::basic_string
|
||||
template<class T> void DrawString (
|
||||
const std::basic_string<T> &text, float scalar, float x,
|
||||
float y, const float *top_color, const float *bottom_color, float alpha, float lastAlpha)
|
||||
float y, const float *top_color, const float *bottom_color, float alpha, float lastAlpha) const
|
||||
{
|
||||
unsigned int i;
|
||||
GLFontChar *glfont_char;
|
||||
float width, height;
|
||||
|
||||
|
||||
//Begin rendering quads
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
|
||||
unsigned int sz = text.size();
|
||||
|
||||
float a = 0;
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
//Get width and height
|
||||
width = (glfont_char->dx * header.tex_width) * scalar;
|
||||
height = (glfont_char->dy * header.tex_height) * scalar;
|
||||
|
||||
|
||||
if (i == (sz-1))
|
||||
a = alpha*lastAlpha;
|
||||
else
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
glVertex3f(x + width, y + height, 0.0F);
|
||||
glTexCoord2f(glfont_char->tx1, glfont_char->ty2);
|
||||
glVertex3f(x, y + height, 0.0F);
|
||||
|
||||
|
||||
//Move to next character
|
||||
x += width;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue