Changeset 5345 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 10, 2005, 12:49:53 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/text_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text.cc
r5344 r5345 83 83 Vector tmpVec; 84 84 85 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize); 86 if (tmpFont != NULL) 87 { 88 if (this->font != NULL) 89 ResourceManager::getInstance()->unload(this->font); 90 this->font = tmpFont; 91 } 92 93 else 94 { 95 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile); 96 if (this->font != NULL) 97 ResourceManager::getInstance()->unload(this->font); 98 this->font = NULL; 85 // unloading the Font if we alrady have one loaded. 86 if (this->font != NULL) 87 ResourceManager::getInstance()->unload(this->font); 88 this->font = NULL; 89 90 // load a new Font 91 if (fontFile != NULL) 92 { 93 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize); 94 if (tmpFont != NULL) 95 this->font = tmpFont; 96 else 97 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile); 99 98 } 100 99 } … … 166 165 } 167 166 167 168 168 /** 169 169 * creates a texture out of the given parameters 170 171 172 170 * 171 * this has to be called every time by the user, to if changes were made. 172 * this is only for TEXT_STATIC-mode 173 173 */ 174 174 void Text::createTexture() 175 175 { 176 SDL_Surface* tmpSurf ;176 SDL_Surface* tmpSurf = NULL; 177 177 if (this->texture) 178 178 glDeleteTextures(1, &this->texture); … … 184 184 theColor); 185 185 } 186 if (tmpSurf) 186 if (tmpSurf != NULL) 187 { 187 188 this->texture = loadTexture(tmpSurf, &this->texCoord); 188 189 189 this->width = tmpSurf->w; 190 this->height = tmpSurf->h; 191 SDL_FreeSurface(tmpSurf); 190 this->width = tmpSurf->w; 191 this->height = tmpSurf->h; 192 SDL_FreeSurface(tmpSurf); 193 } 192 194 } 193 195 … … 289 291 //////////// 290 292 /** 291 * 293 * Loads a Font from an SDL_surface into a texture. 292 294 * @param surface The surface to make the texture of 293 295 * @param texCoord The texture coordinates of the 4 corners of the texture -
trunk/src/lib/graphics/text_engine/text.h
r5344 r5345 59 59 Text(const char* fontFile, unsigned int fontSize = TEXT_DEFAULT_SIZE, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC); 60 60 ~Text(); 61 62 61 void init(); 63 62 64 63 void setFont(const char* fontFile, unsigned int fontSize); 64 65 65 void setType(TEXT_RENDER_TYPE type); 66 66 void setText(const char* text, bool isExtern = false); … … 84 84 85 85 private: 86 87 private:88 86 Font* font; //!< Font of this text 89 87 … … 95 93 96 94 // placement in openGL 97 GLuint texture; //!< A GL-texture to hold the text 95 GLuint texture; //!< A GL-texture to hold the text (static Mode) 98 96 TexCoord texCoord; //!< Texture-coordinates @todo fix this to have a struct 99 97 float height;
Note: See TracChangeset
for help on using the changeset viewer.