Changeset 8758 in orxonox.OLD for branches/fontdata/src/lib/graphics/text_engine
- Timestamp:
- Jun 23, 2006, 10:20:35 PM (18 years ago)
- Location:
- branches/fontdata/src/lib/graphics/text_engine
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/lib/graphics/text_engine/font.cc
r8757 r8758 50 50 this->loadFontFromTTF(fontFile, renderSize); 51 51 } 52 52 53 53 54 /** … … 108 109 { } 109 110 111 Font& Font::operator=(const Font& font) 112 { 113 this->data = font.data; 114 this->setDiffuseMap(font.data->texData); 115 116 return *this; 117 }; 118 119 110 120 /** 111 121 * @brief initializes a Font (with default values) … … 113 123 void Font::init() 114 124 { 125 this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 126 115 127 this->setClassID(CL_FONT, "Font"); 116 128 if (Font::defaultFontData.get() == NULL) … … 152 164 { 153 165 this->setStyle("c"); 154 this->createFastTexture(); 155 if (this->getTexture() != 0) 166 if (this->createFastTexture()) 156 167 return true; 157 168 else … … 186 197 if (newSurf != NULL) 187 198 { 188 this->data-> setSurface(newSurf);189 this->data-> setAlpha(hasAlpha);190 this-> data->setTexture(Texture::loadTexToGL(newSurf));199 this->data->texData->setSurface(newSurf); 200 this->data->texData->setAlpha(hasAlpha); 201 this->setTexture(Texture::loadTexToGL(newSurf)); 191 202 } 192 203 else … … 479 490 // sprintf( outName, "%s-glyphs.bmp", this->getName()); 480 491 // SDL_SaveBMP(tmpSurf, outName); 481 this->data-> setAlpha(true);482 if (this->data-> setSurface(tmpSurf))483 (this->data->setTexture(Texture::loadTexToGL(tmpSurf)));492 this->data->texData->setAlpha(true); 493 if (this->data->texData->setSurface(tmpSurf)) 494 this->setTexture(Texture::loadTexToGL(tmpSurf)); 484 495 return true; 485 496 } 497 498 /** 499 * @brief the Internal implementation of setting up the Texture. 500 * @param texture the Texture to load. 501 * @returns true on success, false otherwise. 502 */ 503 bool Font::setTexture(GLuint texture) 504 { 505 bool retVal = this->data->texData->setTexture(texture); 506 this->setDiffuseMap(data->texData, 0); 507 printf("this->texture %d\n", texture); 508 //printf(this->getT) 509 this->debug(); 510 return retVal; 511 }; 486 512 487 513 /** … … 577 603 void Font::debug() const 578 604 { 605 Material::debug(); 606 607 PRINT(0)("TEST %p and %p\n", this->data.get(), this->data->texData.get()); 579 608 // print the loaded font's style 580 609 int style = TTF_STYLE_NORMAL; -
branches/fontdata/src/lib/graphics/text_engine/font.h
r8756 r8758 17 17 18 18 //! A class to handle a Font of a certain ttf-File/image-file, Size. 19 class Font : public BaseObject/* TODO Material it should be */19 class Font : public Material /* TODO Material it should be */ 20 20 { 21 21 … … 27 27 virtual ~Font(); 28 28 29 Font& operator=(const Font& font) { this->data = font.data; return *this; };29 Font& operator=(const Font& font); 30 30 bool operator==(const Font& font) const { return this->data == font.data; }; 31 31 … … 42 42 inline TTF_Font* getTTF() const { return this->data->getTTF(); }; 43 43 44 inline GLuint getTexture() const { return this->data->getTexture(); };45 46 47 44 int getMaxHeight() const; 48 45 int getMaxAscent() const; … … 52 49 //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; }; 53 50 51 54 52 void createAsciiImage(const std::string& fileName, unsigned int size) const; 55 53 56 void debug() const 54 void debug() const; 57 55 58 56 private: 59 57 void init(); 58 void initGlyphs(Uint16 from, Uint16 count); 60 59 bool getGlyphMetrics(Glyph* glyph, Uint16 character); 60 static void initDefaultFont(); 61 61 62 int findOptimalFastTextureSize(); 62 63 bool createFastTexture(); 63 64 64 void initGlyphs(Uint16 from, Uint16 count); 65 int findOptimalFastTextureSize(); 65 bool setTexture(GLuint texture); 66 66 67 static void initDefaultFont();68 67 69 68 private: -
branches/fontdata/src/lib/graphics/text_engine/font_data.cc
r8756 r8758 27 27 */ 28 28 FontData::FontData() 29 : texData(new TextureData) 29 30 { 31 printf("CREATE FONT_DATA\n"); 30 32 this->fontTTF = NULL; 31 33 this->glyphArray = NULL; -
branches/fontdata/src/lib/graphics/text_engine/font_data.h
r8753 r8758 48 48 49 49 50 class FontData : public TextureData50 class FontData 51 51 { 52 52 friend class Font; 53 53 public: 54 FontData();55 54 ~FontData(); 56 55 … … 65 64 66 65 private: 66 FontData(); 67 68 private: 67 69 TTF_Font* fontTTF; //!< The font we use for this. 68 70 int renderStyle; //!< The Renderstyle … … 70 72 71 73 Glyph** glyphArray; //!< An Array of all the Glyphs stored in the Array of Glyphs. 74 75 TextureDataPointer texData; 72 76 }; 73 77 -
branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc
r8754 r8758 76 76 glActiveTexture(GL_TEXTURE0); 77 77 78 glEnable(GL_BLEND); 79 glEnable(GL_TEXTURE_2D); 80 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 81 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 78 // glEnable(GL_BLEND); 79 // glEnable(GL_TEXTURE_2D); 80 // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 81 // glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 82 // 83 // glBindTexture(GL_TEXTURE_2D, this->font().getTexture()); 84 this->font().select(); 82 85 83 glBindTexture(GL_TEXTURE_2D, this->font().getTexture());84 86 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 85 87 glRotatef(this->getAbsDir2D(), 0, 0, 1); -
branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc
r8754 r8758 76 76 glActiveTexture(GL_TEXTURE0); 77 77 78 glColor4fv(&this->color()[0]);78 /* glColor4fv(&this->color()[0]); 79 79 glEnable(GL_BLEND); 80 80 glEnable(GL_TEXTURE_2D); … … 82 82 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 83 83 84 glBindTexture(GL_TEXTURE_2D, this->font().getTexture()); 84 glBindTexture(GL_TEXTURE_2D, this->font().getTexture());*/ 85 this->font().select(); 85 86 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 86 87 glRotatef(this->getAbsDir2D(), 0, 0, 1); -
branches/fontdata/src/lib/graphics/text_engine/text.cc
r8756 r8758 228 228 229 229 230 glActiveTexture(GL_TEXTURE0);230 /* glActiveTexture(GL_TEXTURE0); 231 231 232 232 glEnable(GL_BLEND); 233 glEnable(GL_TEXTURE_2D);234 233 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 235 234 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 236 235 237 glBindTexture(GL_TEXTURE_2D, this->_font.getTexture()); 236 glBindTexture(GL_TEXTURE_2D, this->_font.getTexture());*/ 237 this->font().select(); 238 //printf("Texture is : %d\n",); 238 239 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 239 240 glRotatef(this->getAbsDir2D(), 0, 0, 1);
Note: See TracChangeset
for help on using the changeset viewer.