X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FText.cpp;h=8f9b1524ef99757edea61e64fc2f5713c8819ea8;hb=b17ec650f79ea8efbfda00ae93bd82434fcea686;hp=e1c2878b4fc4686c665e9421a4f89422872e6a96;hpb=c32ed0b5dc3912d78dbf6d99baeaceb1f51799d7;p=lugaru.git diff --git a/Source/Text.cpp b/Source/Text.cpp index e1c2878..8f9b152 100644 --- a/Source/Text.cpp +++ b/Source/Text.cpp @@ -32,7 +32,7 @@ void Text::LoadFontTexture(const char *fileName) LOG(std::string("Loading font texture...") + fileName); - Game::LoadTexture(fileName, &FontTexture, false, false); + FontTexture.load(fileName, false, false); /* //Load Image //LoadTGA( fileName ); @@ -78,13 +78,15 @@ void Text::BuildFont() // Build Our Font Display List if (base) { - LOG("Font already created..."); - return; + glDeleteLists(base, 512); + base = 0; + //LOG("Font already created..."); + //return; } // base=glGenLists(256); // Creating 256 Display Lists base=glGenLists(512); // Creating 256 Display Lists - glBindTexture(GL_TEXTURE_2D, FontTexture); // Select Our Font Texture + FontTexture.bind(); for (loop=0; loop<512; loop++) // Loop Through All 256 Lists { if (loop < 256) @@ -116,19 +118,19 @@ void Text::BuildFont() // Build Our Font Display List } // Loop Until All 256 Are Built } -void Text::glPrint(float x, float y, char *string, int set, float size, float width, float height) // Where The Printing Happens +void Text::glPrint(float x, float y, const char *string, int set, float size, float width, float height) // Where The Printing Happens { glPrint(x, y, string, set, size, width, height, 0, strlen(string)); } -void Text::_glPrint(float x, float y, char *string, int set, float size, float width, float height,int start,int end, int offset) // Where The Printing Happens +void Text::_glPrint(float x, float y, const char *string, int set, float size, float width, float height,int start,int end, int offset) // Where The Printing Happens { if (set>1) { set=1; } glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - glBindTexture(GL_TEXTURE_2D, FontTexture); // Select Our Font Texture + FontTexture.bind(); glDisable(GL_DEPTH_TEST); // Disables Depth Testing glDisable(GL_LIGHTING); glEnable(GL_BLEND); @@ -152,26 +154,26 @@ void Text::_glPrint(float x, float y, char *string, int set, float size, float w glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); } -void Text::glPrint(float x, float y, char *string, int set, float size, float width, float height,int start,int end) // Where The Printing Happens +void Text::glPrint(float x, float y, const char *string, int set, float size, float width, float height,int start,int end) // Where The Printing Happens { _glPrint(x, y, string, set, size, width, height, start, end, 0); } -void Text::glPrintOutline(float x, float y, char *string, int set, float size, float width, float height) // Where The Printing Happens +void Text::glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height) // Where The Printing Happens { glPrintOutline(x, y, string, set, size, width, height, 0, strlen(string)); } -void Text::glPrintOutline(float x, float y, char *string, int set, float size, float width, float height,int start,int end) // Where The Printing Happens +void Text::glPrintOutline(float x, float y, const char *string, int set, float size, float width, float height,int start,int end) // Where The Printing Happens { _glPrint(x, y, string, set, size, width, height, start, end, 256); } -void Text::glPrintOutlined(float x, float y, char *string, int set, float size, float width, float height) // Where The Printing Happens +void Text::glPrintOutlined(float x, float y, const char *string, int set, float size, float width, float height) // Where The Printing Happens { glPrintOutlined(1, 1, 1, x, y, string, set, size, width, height); } -void Text::glPrintOutlined(float r, float g, float b, float x, float y, char *string, int set, float size, float width, float height) // Where The Printing Happens +void Text::glPrintOutlined(float r, float g, float b, float x, float y, const char *string, int set, float size, float width, float height) // Where The Printing Happens { glColor4f(0,0,0,1); glPrintOutline( x-2*size, y-2*size, string, set, size*2.5/2, width, height); @@ -179,18 +181,14 @@ void Text::glPrintOutlined(float r, float g, float b, float x, float y, char *st glPrint( x, y, string, set, size, width, height); } -Text::Text() -{ +Text::Text() { base = 0; - FontTexture = 0; } -Text::~Text() -{ - if (base) - { +Text::~Text() { + if (base) { glDeleteLists(base, 512); base = 0; } - if (FontTexture) glDeleteTextures( 1, &FontTexture ); + FontTexture.destroy(); }