Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 7, 2005, 4:21:36 PM (19 years ago)
Author:
bensch
Message:

orxonox/braches/textEngine: now shows single char

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc

    r3740 r3747  
    112112  this->fontFile = NULL;
    113113  this->glyphArray = NULL;
     114  this->fastTextureID = 0;
    114115
    115116  this->currentText = new Text;
     
    120121 
    121122  this->setSize(fontSize);
     123  this->setType(TEXT_DYNAMIC);
    122124 
    123125  this->currentText->renderStyle = TTF_STYLE_NORMAL;
     
    134136  this->createTexture();
    135137
    136   this->createFastTexture();
     138  this->fastTextureID = this->createFastTexture();
    137139}
    138140
     
    169171}
    170172
     173/**
     174   \brief sets the Type of this Text
     175   \param type the type to set.
     176*/
     177void GLFont::setType(int type)
     178{
     179  this->currentText->type = type;
     180}
     181
    171182
    172183/**
     
    244255void GLFont::draw(void)
    245256{
     257  // storing all the Transformation Matrices.
    246258  GLdouble modMat[16];
    247259  GLint viewPort[4];
     
    251263  this->enter2DMode();
    252264
    253 
     265  // setting the Position of this Text.
    254266  Vector pos;
    255267  if (this->currentText->bindNode)
     
    271283      pos.z = 0;
    272284    }
    273   glBindTexture(GL_TEXTURE_2D, this->currentText->texture);
    274   glEnable(GL_TEXTURE_2D);
    275   glBegin(GL_QUADS);
    276  
    277   glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV);
    278   glVertex2i(pos.x,   pos.y  );
    279 
    280   glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV);
    281   glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y  );
    282 
    283   glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV);
    284   glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h);
    285 
    286   glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV);
    287   glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h);
    288 
    289   glEnd();
    290 
     285
     286  // drawing this Text.
     287  if(currentText->type == TEXT_STATIC)
     288    {
     289      glBindTexture(GL_TEXTURE_2D, this->currentText->texture);
     290      glEnable(GL_TEXTURE_2D);
     291      glBegin(GL_QUADS);
     292     
     293      glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV);
     294      glVertex2i(pos.x,   pos.y  );
     295     
     296      glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV);
     297      glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y  );
     298     
     299      glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV);
     300      glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h);
     301     
     302      glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV);
     303      glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h);
     304     
     305      glEnd();
     306    }
     307  else //(if currentText->type & TEXT_DYNAMIC)
     308    {
     309      glBindTexture(GL_TEXTURE_2D, this->fastTextureID);
     310      //      glEnable(GL_TEXTURE_2D);
     311      glTranslatef(pos.x, pos.y, 0);
     312
     313      printf("%d, %d\n", this->fastTextureID, glyphArray[65]->displayList);
     314      glCallList(glyphArray[65]->displayList);
     315    }
    291316  this->leave2DMode();
    292317}
     
    443468
    444469  // setting default values. (maybe not needed afterwards)
    445   //  SDL_Color tmpColor;  tmpColor.r = tmpColor.g = tmpColor.b = 0;
     470  SDL_Color tmpColor;  tmpColor.r = tmpColor.g = tmpColor.b = 0;
    446471  // Surface definition.
    447472  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
     
    490515            }
    491516          // reading in the new Glyph
    492           glyphSurf = TTF_RenderGlyph_Blended(this->font,
     517          glyphSurf = TTF_RenderGlyph_Shaded(this->font,
    493518                                              i,
    494                                               this->currentText->color);
    495           //                                     tmpColor);
     519                                              this->currentText->color,
     520          tmpColor);
    496521          if( glyphSurf )
    497522            {
     
    503528              tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
    504529              tmpGlyph->displayList = glGenLists(1);
     530
    505531              glNewList(tmpGlyph->displayList, GL_COMPILE);
    506532              glBegin(GL_QUADS);
     
    508534              glVertex2d(0, 0);
    509535              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
    510               glVertex2d(0, 1);
     536              glVertex2d(0, tmpRect.y);
    511537              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
    512               glVertex2d(1, 1);
     538              glVertex2d(tmpRect.x, tmpRect.y);
    513539              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
    514               glVertex2d(1, 0);
     540              glVertex2d(tmpRect.x, 0);
    515541              glEnd();
    516542              glEndList();
Note: See TracChangeset for help on using the changeset viewer.