Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5124 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Aug 25, 2005, 2:46:34 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: text is now Rendered as expected (in FastMode)

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/graphics_engine.cc

    r5122 r5124  
    466466  this->geTextCFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
    467467  this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
    468   this->geTextCFPS->setAbsCoor2D(5, 5);
     468  this->geTextCFPS->setAbsCoor2D(5, 15);
    469469}
    470470if (this->geTextMaxFPS == NULL)
     
    472472      this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
    473473      this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
    474       this->geTextMaxFPS->setAbsCoor2D(5, 35);
     474      this->geTextMaxFPS->setAbsCoor2D(5, 40);
    475475}
    476476if (this->geTextMinFPS == NULL)
  • trunk/src/lib/graphics/text_engine.cc

    r5123 r5124  
    375375  this->setSize(fontSize);
    376376
    377   this->setFont(fontFile);
     377  this->loadFont(fontFile);
    378378
    379379  this->setStyle("c");//TTF_STYLE_NORMAL);
     
    383383
    384384/**
    385  *  destructs a font
     385 * destructs a font
     386 * this releases the memory a font uses to be opened.
    386387*/
    387388Font::~Font()
     
    407408 * @returns true if loaded, false if something went wrong, or if a font was loaded before.
    408409*/
    409 bool Font::setFont(const char* fontFile)
     410bool Font::loadFont(const char* fontFile)
    410411{
    411412  if (!this->fontFile)
     
    576577            maxLineHeight = tmpGlyph->height;
    577578
    578           if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
     579          if (tmpRect.x+tmpGlyph->advance > tmpSurf->w)
    579580            {
    580581              tmpRect.x = 0;
     
    600601              TexCoord tmpTexCoord;
    601602              tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
    602               tmpTexCoord.maxU = (float)(tmpRect.x +1 + tmpGlyph->width)/(float)tmpSurf->w;
     603              tmpTexCoord.maxU = (float)(tmpRect.x + tmpGlyph->advance)/(float)tmpSurf->w;
    603604              tmpTexCoord.minV = (float)(tmpRect.y)/(float)tmpSurf->w;
    604605              tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
     
    608609              glBegin(GL_QUADS);
    609610              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
    610               glVertex2d(0, 0);
     611              glVertex2d(0, - tmpGlyph->bearingY);
    611612              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
    612               glVertex2d(0, tmpGlyph->height);
     613              glVertex2d(0, tmpGlyph->height - tmpGlyph->bearingY);
    613614              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
    614               glVertex2d(tmpGlyph->width, tmpGlyph->height);
     615              glVertex2d(tmpGlyph->width, tmpGlyph->height - tmpGlyph->bearingY);
    615616              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
    616               glVertex2d(tmpGlyph->width, 0);
     617              glVertex2d(tmpGlyph->width, - tmpGlyph->bearingY);
    617618              glEnd();
    618619              glEndList();
    619620              SDL_FreeSurface(glyphSurf);
    620621
    621               tmpRect.x += tmpGlyph->width + 2;
     622              tmpRect.x += tmpGlyph->advance;
    622623
    623624              // Outputting Glyphs to BMP-files.
     
    693694  int i;
    694695  int x,y; // the counters
    695   int maxLineHeight;
     696  int maxLineHeight = this->getMaxHeight();
    696697  unsigned int size = 32;  // starting Value, we have to start somewhere 32 seems reasonable. (take any small enough 2^i number)
    697698  bool sizeOK = false;
     
    701702    {
    702703      x = 0; y = 0;
    703       maxLineHeight = 0;
    704704      for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    705705        {
     
    710710                maxLineHeight = tmpGlyph->height;
    711711
    712               if (x + tmpGlyph->width > size)
     712              if (x + tmpGlyph->advance > size)
    713713                {
    714714                  x = 0;
     
    718718              if (y + maxLineHeight + 1 > size)
    719719                break;
    720               x += tmpGlyph->width + 1;
     720              x += tmpGlyph->advance;
    721721
    722722            }
     
    727727        size *= 2;
    728728    }
    729   return size;
     729    return size;
    730730}
    731731
  • trunk/src/lib/graphics/text_engine.h

    r5123 r5124  
    158158
    159159  // font
    160   bool setFont(const char* fontFile);
     160  bool loadFont(const char* fontFile);
    161161  void setSize(unsigned int fontSize);
    162162  void setStyle(const char* renderStyle);
     
    165165  inline Glyph** getGlyphArray() const { return glyphArray; };
    166166  /** @returns the texture to the fast-texture */
    167   inline GLuint getFastTextureID() const {return fastTextureID;}
     167  inline GLuint getFastTextureID() const { return fastTextureID; };
    168168
    169169 private:
  • trunk/src/util/shell.cc

    r5123 r5124  
    163163  this->inputLineText->setText(NULL);
    164164  this->inputLineText->setParent2D(this);
    165   this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize);
     165  this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
    166166
    167167  this->setBufferDisplaySize(this->bufferDisplaySize);
     
    746746Vector Shell::calculateLinePosition(unsigned int lineNumber)
    747747{
    748   return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1), 0);
     748  return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) + this->textSize, 0);
    749749}
    750750
Note: See TracChangeset for help on using the changeset viewer.