Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8758 in orxonox.OLD


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

font is a Material now

Location:
branches/fontdata/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/fontdata/src/defs/class_id.h

    r8724 r8758  
    289289  /// Graphical stuff (range from 0x00000800 to 0x00000aff)
    290290  /// SUPER-Textures
    291   CL_TEXTURE                    =    0x00801000,
    292   CL_TEXTURE_SEQUENCE           =    0x00802000,
    293   CL_TEXT                       =    0x00804000,
     291  CL_MATERIAL                   =    0x00801000,
     292  CL_TEXTURE                    =    0x00802000,
     293  CL_TEXTURE_SEQUENCE           =    0x00804000,
     294  CL_TEXT                       =    0x00808000,
    294295  CL_MULTI_LINE_TEXT            =    0x00000840,
    295296  CL_LIMITED_WIDTH_TEXT         =    0x00000841,
     
    315316  CL_BSP_MODEL                  =    0x0000090c, //!FIXME
    316317
    317   CL_MATERIAL                   =    0x00000810,
    318318  CL_SHADER                     =    0x00000811,
    319319  CL_LIGHT                      =    0x00000821,
  • branches/fontdata/src/lib/graphics/importer/material.cc

    r8619 r8758  
    317317}
    318318
     319/**
     320 * @brief Sets the Diffuse map of this Texture by a Texture-pointer.
     321 * @param textureDataPointer The Texture-Data-Pointer to load.
     322 * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS
     323 */
     324void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber)
     325{
     326  assert(textureNumber < Material::getMaxTextureUnits());
     327
     328  if (this->textures.size() <= textureNumber)
     329    this->textures.resize(textureNumber+1, Texture());
     330
     331  this->textures[textureNumber] = textureDataPointer;
     332}
     333
    319334
    320335/**
     
    436451}
    437452
     453
     454
     455void Material::debug() const
     456{
     457  PRINT(0)("Debug Material: %s\n", this->getName());
     458  PRINT(0)("illumModel: %d ; ShiniNess %f\n", this->illumModel, shininess);
     459  PRINT(0)("diffuseColor: "); diffuse.debug();
     460  PRINT(0)("ambientColor: "); ambient.debug();
     461  PRINT(0)("diffuseColor: "); specular.debug();
     462  PRINT(0)("Blending Properties: Source: %s, Destination: %s\n", blendFuncToString(sFactor).c_str(), blendFuncToString(tFactor).c_str());
     463
     464  PRINT(0)("Textures: %d loaded", textures.size());
     465  if (!this->textures.empty())
     466  {
     467    PRINT(0)(" - ID's: ");
     468    for (unsigned int i = 0; i < textures.size(); ++i)
     469    {
     470      PRINT(0)("%d ", textures[i].getTexture());
     471    }
     472  }
     473  PRINT(0)("\n");
     474}
     475
     476
    438477const GLenum Material::glTextureArbs[] =
    439478{
  • branches/fontdata/src/lib/graphics/importer/material.h

    r8619 r8758  
    5353  // MAPPING //
    5454  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
     55  void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0);
    5556  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    5657  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     
    6768  static void addTexturePath(const std::string& pathName);
    6869
    69   const std::string& blendFuncToString(GLenum blendFunc);
    70   GLenum stringToBlendFunc(const std::string& blendFuncString);
     70  static const std::string& blendFuncToString(GLenum blendFunc);
     71  static GLenum stringToBlendFunc(const std::string& blendFuncString);
    7172
     73  void debug() const;
    7274
    7375public:
  • branches/fontdata/src/lib/graphics/importer/texture.cc

    r8376 r8758  
    151151  this->setClassID(CL_TEXTURE, "Texture");
    152152
    153   this->data = CountPointer<TextureData>(new TextureData());
     153  this->data = TextureDataPointer(new TextureData());
    154154
    155155  this->priority = 0.5;
     
    173173  this->data = texture.data;
    174174
     175  return *this;
     176}
     177
     178Texture& Texture::operator=(const TextureDataPointer& textureDataPointer)
     179{
     180  this->data = textureDataPointer;
    175181  return *this;
    176182}
  • branches/fontdata/src/lib/graphics/importer/texture.h

    r8376 r8758  
    2828
    2929  Texture& operator=(const Texture& texture);
     30  Texture& operator=(const TextureDataPointer& textureDataPointer);
    3031
    3132  virtual ~Texture();
     
    6162
    6263private:
    63   CountPointer<TextureData>     data;               //!< The TextureData
     64  TextureDataPointer            data;               //!< The TextureData
    6465  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
    6566
  • branches/fontdata/src/lib/graphics/importer/texture_data.h

    r8751 r8758  
    4343};
    4444
     45typedef CountPointer<TextureData> TextureDataPointer;
     46
    4547#endif /* _TEXTURE_DATA_H */
  • 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.