Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8754 in orxonox.OLD


Ignore:
Timestamp:
Jun 23, 2006, 6:58:01 PM (18 years ago)
Author:
bensch
Message:

better, but still not running, yet

Location:
branches/fontdata/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/fontdata/src/lib/graphics/text_engine/font.cc

    r8753 r8754  
    2929#include "compiler.h"
    3030
     31
     32Font::Font()
     33  : data(Font::defaultFontData)
     34{
     35  this->init();
     36
     37}
    3138
    3239/**
     
    149156bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
    150157{
     158  this->data = FontDataPointer (new FontData());
    151159  // loading to a texture.
    152160  if(surface == NULL)
     
    286294FontDataPointer Font::initDefaultFont()
    287295{
     296  Font::defaultFontData = FontDataPointer(new FontData);
    288297  return Font(font_xpm).data;
    289298}
  • branches/fontdata/src/lib/graphics/text_engine/font.h

    r8753 r8754  
    2121
    2222public:
     23  Font();
    2324  Font(const std::string& fontFile,
    2425       unsigned int renderSize);
     
    2627  Font(char** xpmArray);
    2728  virtual ~Font();
     29
     30  Font& operator=(const Font& font) { this->data = font.data; return *this; };
     31  bool operator==(const Font& font) const { return this->data == font.data; };
    2832
    2933  //  font
  • branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc

    r8619 r8754  
    8181  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    8282
    83   glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
     83  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
    8484  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    8585  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    9090  for (unsigned int i = 0; i < this->_dotedText.size(); i++)
    9191  {
    92     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_dotedText[i]]) != NULL))
     92    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_dotedText[i]]) != NULL))
    9393    {
    9494      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    118118void LimitedWidthText::setupTextWidth()
    119119{
    120   float dotsSize = this->font()->getGlyphArray()[46]->advance * 3.0;
     120  float dotsSize = this->font().getGlyphArray()[46]->advance * 3.0;
    121121
    122122  float width = 0.0f;
     
    134134          this->_dotedText = this->text().substr(0, i) + "...";
    135135          if (i > 0)
    136             width -= this->font()->getGlyphArray()[this->text()[i-1]]->advance;
     136            width -= this->font().getGlyphArray()[this->text()[i-1]]->advance;
    137137          width += dotsSize;
    138138          break;
    139139        }
    140140        // Advance the Text.
    141         if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    142           width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     141        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     142          width += this->font().getGlyphArray()[this->text()[i]]->advance;
    143143      }
    144144      break;
     
    152152          this->_dotedText = std::string("...") + this->text().substr(i);
    153153          if (i + 1 < (int)text().size() )
    154             width -= this->font()->getGlyphArray()[this->text()[i+1]]->advance;
     154            width -= this->font().getGlyphArray()[this->text()[i+1]]->advance;
    155155          width += dotsSize;
    156156          break;
    157157        }
    158158        // Advance the Text.
    159         if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    160           width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     159        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     160          width += this->font().getGlyphArray()[this->text()[i]]->advance;
    161161      }
    162162      break;
  • branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc

    r8619 r8754  
    8282  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    8383
    84   glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
     84  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
    8585  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    8686  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    9999      ++lineNumber;
    100100      posX = 0.0f;
    101       posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight();
     101      posY += this->lineSpacing + this->size(); //this->font().getMaxHeight();
    102102    }
    103103
    104     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL))
     104    if(likely((tmpGlyph = this->font().getGlyphArray()[this->text()[i]]) != NULL))
    105105    {
    106106      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    141141      {
    142142        this->lineEnds.push_back( i -1 );
    143         width = this->font()->getGlyphArray()[this->text()[i-1]]->advance;
     143        width = this->font().getGlyphArray()[this->text()[i-1]]->advance;
    144144      }
    145145      else
     
    148148
    149149    // Advance the Text.
    150     if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    151       width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     150    if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     151      width += this->font().getGlyphArray()[this->text()[i]]->advance;
    152152  }
    153153  this->lineCount = lineEnds.size() + 1;
    154   this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight()));
     154  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font().getMaxHeight()));
    155155}
    156156
  • branches/fontdata/src/lib/graphics/text_engine/text.cc

    r8753 r8754  
    2828 */
    2929Text::Text(const std::string& fontFile, unsigned int textSize)
     30  : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3031{
    3132  this->setClassID(CL_TEXT, "Text");
     
    3839
    3940  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    40 
    41   this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    4241}
    4342
    4443Text::Text(const Text& text)
     44  : _font()
    4545{
    4646  this->setClassID(CL_TEXT, "Text");
    47   this->_font = NULL;
    4847
    4948  *this = text;
     
    9392  this->_color = text._color;
    9493  this->setAlignment(text.getAlignment());
    95   if (this->_font != NULL)
    96     ResourceManager::getInstance()->unload(this->_font);
    97 
    98   this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK
     94
     95  this->_font = text._font;
    9996
    10097  this->_text = text._text;
     
    192189
    193190  // unloading the Font if we alrady have one loaded.
    194   this->_font = newFont;
     191  this->_font = *newFont;
    195192//   if (oldFont != NULL && oldFont != Font::getDefaultFont())
    196193//     ResourceManager::getInstance()->unload(oldFont);
     
    238235  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    239236
    240   glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
     237  glBindTexture(GL_TEXTURE_2D, this->_font.getTexture());
    241238  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    242239  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    247244  for (unsigned int i = 0; i < this->_text.size(); i++)
    248245  {
    249     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
     246    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL))
    250247    {
    251248      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    277274  float width = 0;
    278275  for (unsigned int i = 0; i < this->_text.size(); i++)
    279     if(this->_font->getGlyphArray()[this->_text[i]] != NULL)
    280       width += this->_font->getGlyphArray()[this->_text[i]]->advance;
     276    if(this->_font.getGlyphArray()[this->_text[i]] != NULL)
     277      width += this->_font.getGlyphArray()[this->_text[i]]->advance;
    281278  this->setSizeX2D(width * this->size());
    282279}
     
    288285void Text::debug() const
    289286{
    290   PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str());
     287  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str());
    291288  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());
    292289}
  • branches/fontdata/src/lib/graphics/text_engine/text.h

    r8619 r8754  
    99#include "element_2d.h"
    1010#include "color.h"
     11#include "font.h"
    1112
    1213#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
     
    2021
    2122// FORWARD DECLARATION
    22 class Font;
    2323struct SDL_Surface;
    2424
     
    5858
    5959    /** @returns the pointer to the stored Font (not changeable) */
    60     inline const Font* const font() const { return this->_font; };
     60    inline const Font& font() const { return this->_font; };
    6161    /** @returns the Blending Value [0 invisible 1.0 full visible */
    6262    inline float blending() const { return this->_color.a(); };
     
    7676
    7777  private:
    78     Font*             _font;           //!< Font of this text
     78    Font              _font;           //!< Font of this text
    7979
    8080    std::string       _text;           //!< The text to display
  • branches/fontdata/src/lib/graphics/text_engine/text_engine.cc

    r8753 r8754  
    7575//    while (fontList->size() > 0)
    7676    {
    77       Font* font = dynamic_cast<Font*>(fontList->back());
     77//      Font* font = dynamic_cast<Font*>(fontList->back());
    7878      //if (likely(font != Font::getDefaultFont()))
    7979      //        ResourceManager::getInstance()->unload(font, RP_GAME);
  • branches/fontdata/src/lib/util/count_pointer.h

    r8145 r8754  
    2121        return *this;
    2222    }
     23    bool operator==(const CountPointer& r) const { return this->itsCounter->ptr == r.itsCounter->ptr; };
    2324    X& operator*()  const { return *itsCounter->ptr; }
    2425    X* operator->() const { return itsCounter->ptr; }
Note: See TracChangeset for help on using the changeset viewer.