Changeset 8760 in orxonox.OLD
- Timestamp:
- Jun 24, 2006, 2:14:37 AM (18 years ago)
- Location:
- branches/fontdata/src/lib/graphics/text_engine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/lib/graphics/text_engine/font.h
r8758 r8760 28 28 29 29 Font& operator=(const Font& font); 30 /** @brief compare two fonts @param font the comparator, @returns true if they match */ 30 31 bool operator==(const Font& font) const { return this->data == font.data; }; 31 32 … … 45 46 int getMaxAscent() const; 46 47 int getMaxDescent() const; 47 48 /** @returns the default Font */49 //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };50 51 48 52 49 void createAsciiImage(const std::string& fileName, unsigned int size) const; -
branches/fontdata/src/lib/graphics/text_engine/text.cc
r8759 r8760 28 28 */ 29 29 Text::Text(const std::string& fontFile, unsigned int textSize) 30 : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)30 : _font(fontFile, FONT_DEFAULT_RENDER_SIZE) 31 31 { 32 32 this->setClassID(CL_TEXT, "Text"); … … 35 35 this->_size = textSize; 36 36 this->setSizeY2D(textSize); 37 this-> _color = TEXT_DEFAULT_COLOR;37 this->setColor(TEXT_DEFAULT_COLOR); 38 38 39 39 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); … … 41 41 42 42 Text::Text(const Text& text) 43 : _font()43 : _font() 44 44 { 45 45 this->setClassID(CL_TEXT, "Text"); … … 54 54 Text::~Text() 55 55 { 56 /* if (this->_font != NULL && this->_font != Font::getDefaultFont())57 ResourceManager::getInstance()->unload(this->_font);*/56 /* if (this->_font != NULL && this->_font != Font::getDefaultFont()) 57 ResourceManager::getInstance()->unload(this->_font);*/ 58 58 } 59 59 … … 67 67 return (this->_text == text._text && 68 68 this->_size == text._size && 69 this->_font == text._font && 70 this->_color == text._color); 69 this->_font == text._font ); 71 70 } 72 71 … … 89 88 { 90 89 this->_size = text._size; 91 this->_color = text._color;92 90 this->setAlignment(text.getAlignment()); 93 91 … … 171 169 { 172 170 Font* newFont = NULL; 173 // Font* oldFont = this->_font;171 // Font* oldFont = this->_font; 174 172 175 173 // load a new Font … … 179 177 if (newFont == NULL) 180 178 { 181 // newFont = &Font::();179 // newFont = &Font::(); 182 180 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str()); 183 181 } 184 182 } 185 // if (newFont == NULL) 186 // newFont = Font::getDefaultFont(); 187 assert(newFont != NULL); 188 189 // unloading the Font if we alrady have one loaded. 190 191 this->_font = *newFont; 192 // if (oldFont != NULL && oldFont != Font::getDefaultFont()) 193 // ResourceManager::getInstance()->unload(oldFont); 194 183 184 if (newFont == NULL) 185 this->_font = Font(); 186 else 187 this->_font = *newFont; 188 189 printf("Font Texture is\n" ); 190 _font.debug(); 195 191 this->setupTextWidth(); 196 192 } … … 223 219 glTranslatef(-this->getSizeX2D()/2, 0, 0); 224 220 225 // drawing this Text.226 // setting the Blending effects227 glColor4fv(&this->_color[0]);228 229 221 this->font().select(); 230 222 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); … … 278 270 { 279 271 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str()); 280 PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a());281 } 282 272 // PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a()); 273 } 274 -
branches/fontdata/src/lib/graphics/text_engine/text.h
r8754 r8760 45 45 void setFont(const std::string& fontFile, unsigned int renderSize); 46 46 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 47 inline void setBlending(float blending) { this->_ color.a() = blending; };47 inline void setBlending(float blending) { this->_font.setTransparency(blending); }; 48 48 /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */ 49 void setColor(float r, float g, float b) { this->_ color = Color(r, g, b, this->_color.a()); };50 void setColor(float r, float g, float b, float a) { this->_ color = Color(r, g, b, a); };51 void setColor(const Color& color) { this->_ color = color; };49 void setColor(float r, float g, float b) { this->_font.setDiffuseColor(Color(r, g, b, this->blending())); }; 50 void setColor(float r, float g, float b, float a) { this->_font.setDiffuseColor(Color(r, g, b, a)); }; 51 void setColor(const Color& color) { this->_font.setDiffuseColor(color); }; 52 52 void setSize(float size); 53 53 … … 60 60 inline const Font& font() const { return this->_font; }; 61 61 /** @returns the Blending Value [0 invisible 1.0 full visible */ 62 inline float blending() const { return this->_ color.a(); };62 inline float blending() const { return this->_font.diffuseColor().a(); }; 63 63 /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */ 64 inline const Color& color() const { return this->_ color; };64 inline const Color& color() const { return this->_font.diffuseColor(); }; 65 65 /** @returns the Size of the Text */ 66 66 inline float size() const { return this->_size; }; … … 79 79 80 80 std::string _text; //!< The text to display 81 Color _color; //!< The color of the font.82 81 float _size; //!< The size of the Text. 83 82 };
Note: See TracChangeset
for help on using the changeset viewer.