Changeset 8758 in orxonox.OLD for branches/fontdata
- Timestamp:
- Jun 23, 2006, 10:20:35 PM (18 years ago)
- Location:
- branches/fontdata/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/defs/class_id.h
r8724 r8758 289 289 /// Graphical stuff (range from 0x00000800 to 0x00000aff) 290 290 /// SUPER-Textures 291 CL_TEXTURE = 0x00801000, 292 CL_TEXTURE_SEQUENCE = 0x00802000, 293 CL_TEXT = 0x00804000, 291 CL_MATERIAL = 0x00801000, 292 CL_TEXTURE = 0x00802000, 293 CL_TEXTURE_SEQUENCE = 0x00804000, 294 CL_TEXT = 0x00808000, 294 295 CL_MULTI_LINE_TEXT = 0x00000840, 295 296 CL_LIMITED_WIDTH_TEXT = 0x00000841, … … 315 316 CL_BSP_MODEL = 0x0000090c, //!FIXME 316 317 317 CL_MATERIAL = 0x00000810,318 318 CL_SHADER = 0x00000811, 319 319 CL_LIGHT = 0x00000821, -
branches/fontdata/src/lib/graphics/importer/material.cc
r8619 r8758 317 317 } 318 318 319 /** 320 * @brief Sets the Diffuse map of this Texture by a Texture-pointer. 321 * @param textureDataPointer The Texture-Data-Pointer to load. 322 * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS 323 */ 324 void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber) 325 { 326 assert(textureNumber < Material::getMaxTextureUnits()); 327 328 if (this->textures.size() <= textureNumber) 329 this->textures.resize(textureNumber+1, Texture()); 330 331 this->textures[textureNumber] = textureDataPointer; 332 } 333 319 334 320 335 /** … … 436 451 } 437 452 453 454 455 void Material::debug() const 456 { 457 PRINT(0)("Debug Material: %s\n", this->getName()); 458 PRINT(0)("illumModel: %d ; ShiniNess %f\n", this->illumModel, shininess); 459 PRINT(0)("diffuseColor: "); diffuse.debug(); 460 PRINT(0)("ambientColor: "); ambient.debug(); 461 PRINT(0)("diffuseColor: "); specular.debug(); 462 PRINT(0)("Blending Properties: Source: %s, Destination: %s\n", blendFuncToString(sFactor).c_str(), blendFuncToString(tFactor).c_str()); 463 464 PRINT(0)("Textures: %d loaded", textures.size()); 465 if (!this->textures.empty()) 466 { 467 PRINT(0)(" - ID's: "); 468 for (unsigned int i = 0; i < textures.size(); ++i) 469 { 470 PRINT(0)("%d ", textures[i].getTexture()); 471 } 472 } 473 PRINT(0)("\n"); 474 } 475 476 438 477 const GLenum Material::glTextureArbs[] = 439 478 { -
branches/fontdata/src/lib/graphics/importer/material.h
r8619 r8758 53 53 // MAPPING // 54 54 void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0); 55 void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0); 55 56 void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); 56 57 void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); … … 67 68 static void addTexturePath(const std::string& pathName); 68 69 69 const std::string& blendFuncToString(GLenum blendFunc);70 GLenum stringToBlendFunc(const std::string& blendFuncString);70 static const std::string& blendFuncToString(GLenum blendFunc); 71 static GLenum stringToBlendFunc(const std::string& blendFuncString); 71 72 73 void debug() const; 72 74 73 75 public: -
branches/fontdata/src/lib/graphics/importer/texture.cc
r8376 r8758 151 151 this->setClassID(CL_TEXTURE, "Texture"); 152 152 153 this->data = CountPointer<TextureData>(new TextureData());153 this->data = TextureDataPointer(new TextureData()); 154 154 155 155 this->priority = 0.5; … … 173 173 this->data = texture.data; 174 174 175 return *this; 176 } 177 178 Texture& Texture::operator=(const TextureDataPointer& textureDataPointer) 179 { 180 this->data = textureDataPointer; 175 181 return *this; 176 182 } -
branches/fontdata/src/lib/graphics/importer/texture.h
r8376 r8758 28 28 29 29 Texture& operator=(const Texture& texture); 30 Texture& operator=(const TextureDataPointer& textureDataPointer); 30 31 31 32 virtual ~Texture(); … … 61 62 62 63 private: 63 CountPointer<TextureData>data; //!< The TextureData64 TextureDataPointer data; //!< The TextureData 64 65 GLclampf priority; //!< the priority of the current texture (used for garphics cards with limited mem) 65 66 -
branches/fontdata/src/lib/graphics/importer/texture_data.h
r8751 r8758 43 43 }; 44 44 45 typedef CountPointer<TextureData> TextureDataPointer; 46 45 47 #endif /* _TEXTURE_DATA_H */ -
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.