Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2006, 10:20:35 PM (18 years ago)
Author:
bensch
Message:

font is a Material now

Location:
branches/fontdata/src/lib/graphics/text_engine
Files:
7 edited

Legend:

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

    r8757 r8758  
    5050    this->loadFontFromTTF(fontFile, renderSize);
    5151}
     52
    5253
    5354/**
     
    108109{ }
    109110
     111Font& Font::operator=(const Font& font)
     112{
     113  this->data = font.data;
     114  this->setDiffuseMap(font.data->texData);
     115
     116  return *this;
     117};
     118
     119
    110120/**
    111121 * @brief initializes a Font (with default values)
     
    113123void Font::init()
    114124{
     125  this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     126
    115127  this->setClassID(CL_FONT, "Font");
    116128  if (Font::defaultFontData.get() == NULL)
     
    152164  {
    153165    this->setStyle("c");
    154     this->createFastTexture();
    155     if (this->getTexture() != 0)
     166    if (this->createFastTexture())
    156167      return true;
    157168    else
     
    186197  if (newSurf != NULL)
    187198  {
    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));
    191202  }
    192203  else
     
    479490//       sprintf( outName, "%s-glyphs.bmp", this->getName());
    480491//       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));
    484495  return true;
    485496}
     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 */
     503bool 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};
    486512
    487513/**
     
    577603void Font::debug() const
    578604{
     605  Material::debug();
     606
     607  PRINT(0)("TEST %p and %p\n", this->data.get(), this->data->texData.get());
    579608  // print the loaded font's style
    580609  int style = TTF_STYLE_NORMAL;
  • branches/fontdata/src/lib/graphics/text_engine/font.h

    r8756 r8758  
    1717
    1818//! A class to handle a Font of a certain ttf-File/image-file, Size.
    19 class Font : public BaseObject /* TODO Material it should be */
     19class Font : public Material /* TODO Material it should be */
    2020{
    2121
     
    2727  virtual ~Font();
    2828
    29   Font& operator=(const Font& font) { this->data = font.data; return *this; };
     29  Font& operator=(const Font& font);
    3030  bool operator==(const Font& font) const { return this->data == font.data; };
    3131
     
    4242  inline TTF_Font* getTTF() const { return this->data->getTTF(); };
    4343
    44   inline GLuint getTexture() const { return this->data->getTexture(); };
    45 
    46 
    4744  int getMaxHeight() const;
    4845  int getMaxAscent() const;
     
    5249  //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
    5350
     51
    5452  void createAsciiImage(const std::string& fileName, unsigned int size) const;
    5553
    56   void debug() const ;
     54  void debug() const;
    5755
    5856private:
    5957  void init();
     58  void initGlyphs(Uint16 from, Uint16 count);
    6059  bool getGlyphMetrics(Glyph* glyph, Uint16 character);
     60  static void initDefaultFont();
    6161
     62  int findOptimalFastTextureSize();
    6263  bool createFastTexture();
    6364
    64   void initGlyphs(Uint16 from, Uint16 count);
    65   int findOptimalFastTextureSize();
     65  bool setTexture(GLuint texture);
    6666
    67   static void initDefaultFont();
    6867
    6968private:
  • branches/fontdata/src/lib/graphics/text_engine/font_data.cc

    r8756 r8758  
    2727 */
    2828FontData::FontData()
     29  : texData(new TextureData)
    2930{
     31  printf("CREATE FONT_DATA\n");
    3032  this->fontTTF = NULL;
    3133  this->glyphArray = NULL;
  • branches/fontdata/src/lib/graphics/text_engine/font_data.h

    r8753 r8758  
    4848
    4949
    50 class FontData : public TextureData
     50class FontData
    5151{
    5252  friend class Font;
    5353public:
    54   FontData();
    5554  ~FontData();
    5655
     
    6564
    6665private:
     66  FontData();
     67
     68private:
    6769  TTF_Font*     fontTTF;             //!< The font we use for this.
    6870  int           renderStyle;         //!< The Renderstyle
     
    7072
    7173  Glyph**       glyphArray;          //!< An Array of all the Glyphs stored in the Array of Glyphs.
     74
     75  TextureDataPointer   texData;
    7276};
    7377
  • branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc

    r8754 r8758  
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    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();
    8285
    83   glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
    8486  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    8587  glRotatef(this->getAbsDir2D(), 0, 0, 1);
  • branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc

    r8754 r8758  
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    78   glColor4fv(&this->color()[0]);
     78/*  glColor4fv(&this->color()[0]);
    7979  glEnable(GL_BLEND);
    8080  glEnable(GL_TEXTURE_2D);
     
    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());*/
     85  this->font().select();
    8586  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    8687  glRotatef(this->getAbsDir2D(), 0, 0, 1);
  • branches/fontdata/src/lib/graphics/text_engine/text.cc

    r8756 r8758  
    228228
    229229
    230   glActiveTexture(GL_TEXTURE0);
     230/*  glActiveTexture(GL_TEXTURE0);
    231231
    232232  glEnable(GL_BLEND);
    233   glEnable(GL_TEXTURE_2D);
    234233  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    235234  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    236235
    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",);
    238239  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    239240  glRotatef(this->getAbsDir2D(), 0, 0, 1);
Note: See TracChangeset for help on using the changeset viewer.