Changeset 9839 in orxonox.OLD for branches/new_class_id/src/lib/graphics
- Timestamp:
- Sep 26, 2006, 6:31:56 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/Makefile.am
r9820 r9839 21 21 text_engine/limited_width_text.cc \ 22 22 text_engine/font.cc \ 23 text_engine/font_data.cc 23 text_engine/font_data.cc \ 24 text_engine/resource_font.cc 24 25 25 26 noinst_HEADERS =\ … … 41 42 text_engine/font.h \ 42 43 text_engine/font_data.h \ 44 text_engine/resource_font.h \ 43 45 text_engine/default_font.xpm 44 46 -
branches/new_class_id/src/lib/graphics/text_engine/font.cc
r9723 r9839 35 35 { 36 36 this->init(); 37 38 37 } 39 38 … … 119 118 Material::operator=(font); 120 119 this->data = font.data; 120 this->setTexture(this->data->textureData()); 121 121 122 122 return *this; -
branches/new_class_id/src/lib/graphics/text_engine/resource_font.cc
r9838 r9839 6 6 7 7 8 ResourceFont::ResourceFont(const std::string& imageName, GLenum target)9 :NewResource(&ResourceFont::type)8 ResourceFont::ResourceFont(const std::string& fontName, unsigned int renderSize) 9 : Font(), NewResource(&ResourceFont::type) 10 10 { 11 Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST"); 11 assert(!fontName.empty()); 12 Resources::StorePointer* ptr = this->acquireResource(fontName + ',' + MultiType((int)renderSize).getString()); 12 13 13 14 if (ptr) 14 15 { 15 PRINTF(5)("FOUND FONT: %s\n", imageName.c_str());16 this-> acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr());16 PRINTF(5)("FOUND FONT: %s\n", fontName.c_str()); 17 this->Font::acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr()); 17 18 } 18 19 else 19 20 { 20 PRINTF(5)("NOT FOUND FONT: %s\n", imageName.c_str()); 21 std::string fileName = this->NewResource::locateFile(imageName); 22 this->Font::loadImage(fileName, target); 23 this->NewResource::addResource(new ResourceFont::FontResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Font::dataPointer())); 21 PRINTF(5)("NOT FOUND FONT: %s\n", fontName.c_str()); 22 std::string fileName = this->NewResource::locateFile(fontName); 23 24 printf("FONTFILE %s TO %s\n", fontName.c_str(), fileName.c_str()); 25 26 this->Font::loadFontFromTTF(fileName, renderSize); 27 this->NewResource::addResource(new ResourceFont::FontResourcePointer(fontName + ',' + MultiType((int)renderSize).getString(), Resources::KeepLevel(0), this->Font::dataPointer())); 24 28 } 25 29 } … … 28 32 { 29 33 SubString loadValues(loadString, ','); 30 std::string imageName;31 GLenum target = GL_FONT_2D;34 std::string fontName; 35 unsigned int renderSize = 20; 32 36 if (loadValues.size() > 0) 33 imageName = loadValues[0];37 fontName = loadValues[0]; 34 38 if (loadValues.size() > 1) 35 target = (GLenum)MultiType(loadValues[2]).getInt();39 renderSize = (unsigned int)MultiType(loadValues[2]).getInt(); 36 40 37 return ResourceFont( imageName, target);41 return ResourceFont(fontName, renderSize); 38 42 } 39 43 -
branches/new_class_id/src/lib/graphics/text_engine/resource_font.h
r9838 r9839 15 15 { 16 16 public: 17 ResourceFont(const std::string& imageName, GLenum target = GL_FONT_2D);17 ResourceFont(const std::string& fontName, unsigned int renderSize); 18 18 static ResourceFont createFromString(const std::string& loadString); 19 19 -
branches/new_class_id/src/lib/graphics/text_engine/text.cc
r9836 r9839 17 17 18 18 #include "text.h" 19 #include "resource_font.h" 19 20 #include "font.h" 20 #include "loading/old_resource_manager.h"21 21 #include "debug.h" 22 22 … … 29 29 */ 30 30 Text::Text(const std::string& fontFile, unsigned int textSize) 31 31 // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE) 32 32 { 33 33 this->registerObject(this, Text::_objectList); 34 34 35 35 // initialize this Text 36 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 36 if (!fontFile.empty()) 37 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 38 else 39 this->setFont("fonts/final_frontier.ttf", FONT_DEFAULT_RENDER_SIZE); 37 40 this->_size = textSize; 38 41 this->setSizeY2D(textSize); … … 170 173 void Text::setFont(const std::string& fontFile, unsigned int fontSize) 171 174 { 172 Font* newFont = NULL; 173 // Font* oldFont = this->_font; 174 175 // load a new Font 176 if (!fontFile.empty()) 177 { 178 newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize); 179 if (newFont == NULL) 180 { 181 // newFont = &Font::(); 182 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str()); 183 } 184 } 185 186 if (newFont == NULL) 187 this->_font = Font(); 188 else 189 this->_font = *newFont; 175 this->_font = ResourceFont(fontFile, fontSize); 190 176 191 177 this->setupTextWidth();
Note: See TracChangeset
for help on using the changeset viewer.