diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index 77e2697..f16de8e 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -77,7 +77,7 @@ KeyframeWidget::KeyframeWidget(int key) : Quad() { setTexture("keyframe"); setWidthHeight(15, 30); - b = new BitmapText(&dsq->smallFont); + b = new BitmapText(dsq->smallFont); b->position = Vector(1, -15); b->setFontSize(12); addChild(b, PM_POINTER); diff --git a/Aquaria/AquariaComboBox.cpp b/Aquaria/AquariaComboBox.cpp index a1c4707..d4841e5 100644 --- a/Aquaria/AquariaComboBox.cpp +++ b/Aquaria/AquariaComboBox.cpp @@ -42,7 +42,7 @@ AquariaComboBox::AquariaComboBox(Vector textscale) : RenderObject() scrollBtnDown->alpha = 0; addChild(scrollBtnDown, PM_POINTER); - selectedItemLabel = new BitmapText(&dsq->smallFont); + selectedItemLabel = new BitmapText(dsq->smallFont); selectedItemLabel->setAlign(ALIGN_LEFT); selectedItemLabel->setFontSize(8); selectedItemLabel->offset.y = -10; @@ -355,7 +355,7 @@ AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, size_t idx, Aqu setTexture("gui/combo-drop"); - label = new BitmapText(&dsq->smallFont); + label = new BitmapText(dsq->smallFont); label->setAlign(ALIGN_LEFT); label->setFontSize(8); label->setText(str); diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index cc6a770..9f2e9fd 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -937,12 +937,12 @@ AquariaMenuItem::AquariaMenuItem() : Quad(), ActionMapper(), AquariaGuiElement() font = 0; - font = new BitmapText(&dsq->font); + font = new BitmapText(dsq->font); font->setFontSize(sz); font->position = Vector(0, -sz/2, 0); addChild(font, PM_POINTER, RBP_ON); - glowFont = new BitmapText(&dsq->font); + glowFont = new BitmapText(dsq->font); glowFont->setFontSize(sz); glowFont->position = Vector(0, -sz/2, 0); glowFont->setBlendType(BLEND_ADD); diff --git a/Aquaria/AquariaSaveSlot.cpp b/Aquaria/AquariaSaveSlot.cpp index cd8a064..194c152 100644 --- a/Aquaria/AquariaSaveSlot.cpp +++ b/Aquaria/AquariaSaveSlot.cpp @@ -40,10 +40,10 @@ AquariaSaveSlot::AquariaSaveSlot(int slot) : AquariaGuiQuad() - text1 = new BitmapText(&dsq->smallFont); + text1 = new BitmapText(dsq->smallFont); text1->setFontSize(14); - glowText = new BitmapText(&dsq->smallFont); + glowText = new BitmapText(dsq->smallFont); glowText->alpha = 0; glowText->setBlendType(BLEND_ADD); glowText->setFontSize(14); diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 38d0297..9880144 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -350,9 +350,9 @@ void DSQ::centerMessage(const std::string &text, float y, int type) BitmapText *t = 0; if (type == 1) - t = new BitmapText(&smallFontRed); + t = new BitmapText(smallFontRed); else - t = new BitmapText(&smallFont); + t = new BitmapText(smallFont); t->position = pos; t->alpha.ensureData(); t->alpha.data->path.addPathNode(1, 0); @@ -372,7 +372,7 @@ void DSQ::centerText(const std::string &text) Vector pos(400,200); float time = 8; - BitmapText *s = new BitmapText(&font); + BitmapText *s = new BitmapText(font); s->color = Vector(0,0,0); s->position = pos; s->offset = Vector(1,1); @@ -389,7 +389,7 @@ void DSQ::centerText(const std::string &text) getTopStateData()->addRenderObject(s, LR_HUD); - BitmapText *t = new BitmapText(&font); + BitmapText *t = new BitmapText(font); t->position =pos; @@ -1053,7 +1053,7 @@ void DSQ::init() debugLog("2"); - versionLabel = new BitmapText(&smallFont); + versionLabel = new BitmapText(smallFont); { setVersionLabelText(); @@ -1076,7 +1076,7 @@ void DSQ::init() subbox->color = 0; addRenderObject(subbox, LR_SUBTITLES); - subtext = new BitmapText(&dsq->subsFont); + subtext = new BitmapText(dsq->subsFont); subtext->position = Vector(400,570); subtext->followCamera = 1; @@ -1096,7 +1096,7 @@ void DSQ::init() achievement_box->color = 0; addRenderObject(achievement_box, LR_SUBTITLES); - achievement_text = new BitmapText(&dsq->subsFont); + achievement_text = new BitmapText(dsq->subsFont); achievement_text->position = Vector(603, 5); achievement_text->followCamera = 1; achievement_text->alpha = 0; @@ -1115,14 +1115,14 @@ void DSQ::init() cutscene_bg->followCamera = 1; addRenderObject(cutscene_bg, LR_SUBTITLES); - cutscene_text = new BitmapText(&dsq->font); + cutscene_text = new BitmapText(dsq->font); cutscene_text->setText(stringbank.get(2004)); cutscene_text->position = Vector(400,300-16); cutscene_text->alpha.x = 0; cutscene_text->followCamera = 1; addRenderObject(cutscene_text, LR_SUBTITLES); - cutscene_text2 = new BitmapText(&dsq->smallFont); + cutscene_text2 = new BitmapText(dsq->smallFont); cutscene_text2->setText(stringbank.get(2005)); cutscene_text2->position = Vector(400,300+10); cutscene_text2->alpha.x = 0; @@ -2559,7 +2559,7 @@ void DSQ::createSaveSlots(SaveSlotMode ssm) watch(t); - saveSlotPageCount = new BitmapText(&dsq->smallFont); + saveSlotPageCount = new BitmapText(dsq->smallFont); saveSlotPageCount->followCamera = 1; saveSlotPageCount->setAlign(ALIGN_LEFT); saveSlotPageCount->position = Vector(590, 300); @@ -2605,7 +2605,7 @@ void DSQ::createSaveSlots(SaveSlotMode ssm) menu[3] = arrowDown; - BitmapText *txt = new BitmapText(&dsq->font); + BitmapText *txt = new BitmapText(dsq->font); if (ssm == SSM_LOAD) txt->setText(stringbank.get(2001)); else @@ -3035,7 +3035,7 @@ bool DSQ::confirm(const std::string &text, const std::string &image, bool ok, fl yes->setDirMove(DIR_LEFT, yes); } - BitmapText *txt = new BitmapText(&dsq->smallFont); + BitmapText *txt = new BitmapText(dsq->smallFont); txt->followCamera = 1; txt->position = Vector(400,250); txt->setText(text); diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index dba0aed..4bf3539 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2831,7 +2831,7 @@ void Game::applyState() } addRenderObject(controlHint_bg, LR_HELP); - controlHint_text = new BitmapText(&dsq->smallFont); + controlHint_text = new BitmapText(dsq->smallFont); { controlHint_text->alpha = 0; controlHint_text->setWidth(700); @@ -3007,7 +3007,7 @@ void Game::applyState() miniMapRender->scale = Vector(0.55f, 0.55f); addRenderObject(miniMapRender, LR_MINIMAP); - timerText = new BitmapText(&dsq->smallFont); + timerText = new BitmapText(dsq->smallFont); timerText->position = Vector(745, 550); timerText->alpha = 0; timerText->followCamera = 1; diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp index 108a60d..5587865 100644 --- a/Aquaria/InGameMenu.cpp +++ b/Aquaria/InGameMenu.cpp @@ -1726,7 +1726,7 @@ void InGameMenu::create() float scale = menuBg->scale.x; /* - songDescription = new BitmapText(&dsq->font); + songDescription = new BitmapText(dsq->font); songDescription->position = Vector(0,100); songDescription->parentManagedPointer = 1; menuBg->addChild(songDescription); @@ -1902,7 +1902,7 @@ void InGameMenu::create() // Vector(575,250); - songLabel = new BitmapText(&dsq->smallFont); + songLabel = new BitmapText(dsq->smallFont); { songLabel->alpha = 0; songLabel->setAlign(ALIGN_CENTER); @@ -2296,7 +2296,7 @@ void InGameMenu::create() nextTreasure->setCanDirMove(false); game->addRenderObject(nextTreasure, LR_MENU); - circlePageNum = new BitmapText(&dsq->smallFont); + circlePageNum = new BitmapText(dsq->smallFont); circlePageNum->color = Vector(0,0,0); circlePageNum->position = worldLeftCenter + Vector(0, -142); circlePageNum->alpha = 0; @@ -2342,7 +2342,7 @@ void InGameMenu::create() recipeMenu.scrollEnd->alpha = 0; game->addRenderObject(recipeMenu.scrollEnd, LR_RECIPES); - recipeMenu.header = new BitmapText(&dsq->font); + recipeMenu.header = new BitmapText(dsq->font); recipeMenu.header->color = 0; recipeMenu.header->followCamera = 1; recipeMenu.header->setText(stringbank.get(2007)); @@ -2350,7 +2350,7 @@ void InGameMenu::create() recipeMenu.header->position = Vector(scrollx, 5); //10 game->addRenderObject(recipeMenu.header, LR_RECIPES); - recipeMenu.page = new BitmapText(&dsq->smallFont); + recipeMenu.page = new BitmapText(dsq->smallFont); recipeMenu.page->color = 0; recipeMenu.page->followCamera = 1; recipeMenu.page->position = Vector(scrollx, 400); @@ -2423,7 +2423,7 @@ void InGameMenu::create() menuBg->addChild(songSlots[i], PM_POINTER); } - menuDescription = new BitmapText(&dsq->smallFont); + menuDescription = new BitmapText(dsq->smallFont); menuDescription->setFontSize(14); menuDescription->position = Vector(400, 450); menuDescription->setAlign(ALIGN_CENTER); @@ -2595,7 +2595,7 @@ void InGameMenu::create() } - foodLabel = new BitmapText(&dsq->smallFont); + foodLabel = new BitmapText(dsq->smallFont); { foodLabel->alpha = 0; foodLabel->setAlign(ALIGN_CENTER); @@ -2606,7 +2606,7 @@ void InGameMenu::create() } menuBg->addChild(foodLabel, PM_POINTER); - foodDescription = new BitmapText(&dsq->smallFont); + foodDescription = new BitmapText(dsq->smallFont); { foodDescription->alpha = 0; foodDescription->setAlign(ALIGN_CENTER); @@ -2643,7 +2643,7 @@ void InGameMenu::create() game->addRenderObject(treasureSlots[i], LR_MENU); } - treasureLabel = new BitmapText(&dsq->smallFont); + treasureLabel = new BitmapText(dsq->smallFont); { treasureLabel->alpha = 0; treasureLabel->setAlign(ALIGN_CENTER); diff --git a/Aquaria/ModSelector.cpp b/Aquaria/ModSelector.cpp index 20ee930..c3e8e29 100644 --- a/Aquaria/ModSelector.cpp +++ b/Aquaria/ModSelector.cpp @@ -43,10 +43,10 @@ static bool _modname_cmp(const ModIcon *a, const ModIcon *b) ModSelectorScreen::ModSelectorScreen() : Quad() , ActionMapper() - , dlText(&dsq->smallFont) + , dlText(dsq->smallFont) , gotServerList(false) , currentPanel(-1) - , subtext(&dsq->subsFont) + , subtext(dsq->subsFont) { followCamera = 1; shareAlphaWithChildren = false; @@ -377,7 +377,7 @@ void ModSelectorScreen::close() dsq->toggleVersionLabel(true); } -JuicyProgressBar::JuicyProgressBar() : Quad(), txt(&dsq->smallFont) +JuicyProgressBar::JuicyProgressBar() : Quad(), txt(dsq->smallFont) { setTexture("modselect/tube"); followCamera = 1; diff --git a/Aquaria/RecipeMenuEntry.cpp b/Aquaria/RecipeMenuEntry.cpp index 6d23cdb..57aaf3a 100644 --- a/Aquaria/RecipeMenuEntry.cpp +++ b/Aquaria/RecipeMenuEntry.cpp @@ -60,7 +60,7 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe result->scale = Vector(0.7f, 0.7f); addChild(result, PM_POINTER); - BitmapText *text = new BitmapText(&dsq->smallFont); + BitmapText *text = new BitmapText(dsq->smallFont); text->scale = Vector(0.7f, 0.7f); text->color = 0; text->position = result->position + Vector(0, 18); @@ -100,7 +100,7 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe ing[c]->scale = Vector(0.7f, 0.7f); addChild(ing[c], PM_POINTER); - BitmapText *text = new BitmapText(&dsq->smallFont); + BitmapText *text = new BitmapText(dsq->smallFont); text->scale = Vector(0.7f, 0.7f); text->color = 0; text->position = ing[c]->position + Vector(0, 18); @@ -130,7 +130,7 @@ RecipeMenuEntry::RecipeMenuEntry(Recipe *recipe) : RenderObject(), recipe(recipe for (int j = 0; j < recipe->types[i].amount; j++) { // any type of whatever... - BitmapText *text = new BitmapText(&dsq->smallFont); + BitmapText *text = new BitmapText(dsq->smallFont); text->color = 0; text->scale = Vector(0.8f, 0.8f); text->position = Vector(100*c, 0); @@ -418,7 +418,7 @@ void RecipeMenu::createPage(int p) } - description = new BitmapText(&dsq->smallFont); + description = new BitmapText(dsq->smallFont); description->followCamera = 1; description->scale = Vector(0.7f, 0.7f); description->setAlign(ALIGN_LEFT); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index efbc4d0..da35e5b 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -4426,6 +4426,7 @@ luaFunc(entity_isFollowingPath) luaReturnBool(false); } +// deprecated luaFunc(entity_toggleBone) { Entity *e = entity(L); @@ -5705,7 +5706,7 @@ luaFunc(entity_debugText) const char *txt = lua_tostring(L, 2); if (e && txt) { - BitmapText *f = new BitmapText(&dsq->smallFont); + BitmapText *f = new BitmapText(dsq->smallFont); f->setText(txt); f->position = e->position; core->getTopStateData()->addRenderObject(f, LR_DEBUG_TEXT); @@ -9418,8 +9419,7 @@ luaFunc(createDebugText) luaFunc(createBitmapText) { - BmpFont *font = &dsq->smallFont; - BitmapText *txt = new BitmapText(font); + BitmapText *txt = new BitmapText(dsq->smallFont); txt->setText(getString(L, 1)); txt->setFontSize(lua_tointeger(L, 2)); txt->position = Vector(lua_tonumber(L, 3), lua_tonumber(L, 4)); diff --git a/Aquaria/ToolTip.cpp b/Aquaria/ToolTip.cpp index f5a02bb..4daed4e 100644 --- a/Aquaria/ToolTip.cpp +++ b/Aquaria/ToolTip.cpp @@ -38,7 +38,7 @@ ToolTip::ToolTip() : RenderObject() back->renderCenter = false; addChild(back, PM_POINTER); - text = new BitmapText(&dsq->smallFont); + text = new BitmapText(dsq->smallFont); text->alpha = 0.9f; text->setAlign(ALIGN_LEFT); addChild(text, PM_POINTER); diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index 4ad8bf7..2960197 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -704,7 +704,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() float sz = 0.6f; //hover - areaLabel = new BitmapText(&dsq->smallFont); + areaLabel = new BitmapText(dsq->smallFont); areaLabel->scale = Vector(sz,sz); areaLabel->setAlign(ALIGN_CENTER); @@ -714,7 +714,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() areaLabel->alpha = 0; //in - areaLabel2 = new BitmapText(&dsq->smallFont); + areaLabel2 = new BitmapText(dsq->smallFont); areaLabel2->scale = Vector(sz,sz); areaLabel2->followCamera = 1; @@ -724,7 +724,7 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() areaLabel2->alpha = 0; //select - areaLabel3 = new BitmapText(&dsq->smallFont); + areaLabel3 = new BitmapText(dsq->smallFont); areaLabel3->scale = Vector(sz,sz); areaLabel3->followCamera = 1; diff --git a/BBGE/BitmapFont.cpp b/BBGE/BitmapFont.cpp index 7b6f013..f71e5fb 100644 --- a/BBGE/BitmapFont.cpp +++ b/BBGE/BitmapFont.cpp @@ -70,10 +70,9 @@ void BmpFont::load(const std::string &file, float scale, bool loadTexture) loaded = true; } -BitmapText::BitmapText(BmpFont *bmpFont) +BitmapText::BitmapText(const BmpFont& bmpFont) + : bmpFont(bmpFont) { - this->bmpFont = bmpFont; - currentScrollLine = currentScrollChar = 0; scrollDelay = 0; scrolling = false; @@ -126,13 +125,13 @@ float BitmapText::getSetWidth() float BitmapText::getHeight() const { - float sz = bmpFont->font->GetCharHeight('A') * bmpFont->scale; + float sz = bmpFont.font->GetCharHeight('A') * bmpFont.scale; return lines.size()*sz; } float BitmapText::getLineHeight() const { - return bmpFont->font->GetCharHeight('A') * bmpFont->scale; + return bmpFont.font->GetCharHeight('A') * bmpFont.scale; } void BitmapText::formatText() @@ -148,7 +147,7 @@ void BitmapText::formatText() for (size_t i = 0; i < text.size(); i++) { - float sz = bmpFont->font->GetCharWidth(text[i])*bmpFont->scale; + float sz = bmpFont.font->GetCharWidth(text[i])*bmpFont.scale; currentWidth += sz; if (currentWidth+sz >= textWidth || text[i] == '\n') @@ -268,22 +267,24 @@ Vector BitmapText::getColorIndex(size_t i, size_t j) void BitmapText::onRender(const RenderState& rs) const { - if (!bmpFont) return; - float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z}; - float bottom_color[3] = {bmpFont->fontBtmColor.x*color.x, bmpFont->fontBtmColor.y*color.y, bmpFont->fontBtmColor.z*color.z}; + const Vector top = bmpFont.fontTopColor; + const Vector btm = bmpFont.fontBtmColor; + float top_color[3] = {top.x*color.x, top.y*color.y, top.z*color.z}; + float bottom_color[3] = {btm.x*color.x, btm.y*color.y, btm.z*color.z}; glEnable(GL_TEXTURE_2D); + const glfont::GLFont * const font = bmpFont.font; + font->Begin(); - bmpFont->font->Begin(); - - if (bmpFont->overrideTexture) bmpFont->overrideTexture->apply(); + if (bmpFont.overrideTexture) bmpFont.overrideTexture->apply(); + const float scale = bmpFont.scale; float y=0; float x=0; - float adj = bmpFont->font->GetCharHeight('A') * bmpFont->scale; + float adj = font->GetCharHeight('A') * scale; if (scrolling) { @@ -297,13 +298,13 @@ void BitmapText::onRender(const RenderState& rs) const if (align == ALIGN_CENTER) { std::pair sz; - bmpFont->font->GetStringSize(lines[i], &sz); - x = -sz.first*0.5f*bmpFont->scale; + font->GetStringSize(lines[i], &sz); + x = -sz.first*0.5f*scale; } float la = 1.0f-(scrollDelay/scrollSpeed); - bmpFont->font->DrawString(theLine, bmpFont->scale, x, y, top_color, bottom_color, alpha.x, la); + font->DrawString(theLine, scale, x, y, top_color, bottom_color, alpha.x, la); y += adj; } } @@ -315,10 +316,10 @@ void BitmapText::onRender(const RenderState& rs) const if (align == ALIGN_CENTER) { std::pair sz; - bmpFont->font->GetStringSize(lines[i], &sz); - x = -sz.first*0.5f*bmpFont->scale; + font->GetStringSize(lines[i], &sz); + x = -sz.first*0.5f*scale; } - bmpFont->font->DrawString(lines[i], bmpFont->scale, x, y, top_color, bottom_color, alpha.x, 1); + font->DrawString(lines[i], scale, x, y, top_color, bottom_color, alpha.x, 1); y += adj; } } @@ -364,7 +365,7 @@ float BitmapText::getStringWidth(const std::string& text) const if(text[i] == '\n') { std::pair dim; - bmpFont->font->GetStringSize(tmp, &dim); + bmpFont.font->GetStringSize(tmp, &dim); maxsize = std::max(maxsize, dim.first); tmp.resize(0); } @@ -372,10 +373,10 @@ float BitmapText::getStringWidth(const std::string& text) const tmp += text[i]; } std::pair dim; - bmpFont->font->GetStringSize(tmp, &dim); + bmpFont.font->GetStringSize(tmp, &dim); maxsize = std::max(maxsize, dim.first); - return maxsize * bmpFont->scale; + return maxsize * bmpFont.scale; } diff --git a/BBGE/BitmapFont.h b/BBGE/BitmapFont.h index 8cecdf0..ade436b 100644 --- a/BBGE/BitmapFont.h +++ b/BBGE/BitmapFont.h @@ -47,7 +47,7 @@ struct BmpFont class BitmapText : public BaseText { public: - BitmapText(BmpFont *bmpFont); + BitmapText(const BmpFont& bmpFont); void setText(const std::string &text) OVERRIDE; void setWidth(float width) OVERRIDE; float getSetWidth(); // get the width that was set @@ -71,8 +71,8 @@ public: size_t getNumLines() const OVERRIDE; protected: + const BmpFont& bmpFont; float scrollSpeed; - BmpFont *bmpFont; void onUpdate(float dt) OVERRIDE; float scrollDelay; bool scrolling; diff --git a/ExternalLibs/glfont2/glfont2.cpp b/ExternalLibs/glfont2/glfont2.cpp index e9359e6..07bb654 100644 --- a/ExternalLibs/glfont2/glfont2.cpp +++ b/ExternalLibs/glfont2/glfont2.cpp @@ -151,45 +151,45 @@ void GLFont::Destroy (void) } } //******************************************************************* -void GLFont::GetTexSize (std::pair *size) +void GLFont::GetTexSize (std::pair *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 *interval) +void GLFont::GetCharInterval (std::pair *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 *size) +void GLFont::GetCharSize (unsigned char c, std::pair *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 *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 *size) +void GLFont::GetStringSize (const std::string &text, std::pair *size) const { unsigned int i; unsigned int c; diff --git a/ExternalLibs/glfont2/glfont2.h b/ExternalLibs/glfont2/glfont2.h index 235869b..73f5ec0 100644 --- a/ExternalLibs/glfont2/glfont2.h +++ b/ExternalLibs/glfont2/glfont2.h @@ -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 *size); - int GetTexWidth (void); - int GetTexHeight (void); + void GetTexSize (std::pair *size) const; + int GetTexWidth (void) const; + int GetTexHeight (void) const; //Character interval retrieval methods - void GetCharInterval (std::pair *interval); - int GetStartChar (void); - int GetEndChar (void); + void GetCharInterval (std::pair *interval) const; + int GetStartChar (void) const; + int GetEndChar (void) const; //Character size retrieval methods - void GetCharSize (unsigned char c, std::pair *size); - int GetCharWidth (unsigned char c); - int GetCharHeight (unsigned char c); - - void GetStringSize (const std::string &text, std::pair *size); + void GetCharSize (unsigned char c, std::pair *size) const; + int GetCharWidth (unsigned char c) const; + int GetCharHeight (unsigned char c) const; + + void GetStringSize (const std::string &text, std::pair *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 void DrawString ( const std::basic_string &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; }