Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8619 in orxonox.OLD


Ignore:
Timestamp:
Jun 20, 2006, 1:24:11 PM (18 years ago)
Author:
bensch
Message:

trunk: merged the gui-branche back.
merged with command:
svn merge -r8520:HEAD https://svn.orxonox.net/orxonox/branches/gui
no conflicts

Location:
trunk/src
Files:
2 deleted
39 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r8518 r8619  
    287287  CL_TEXT                       =    0x00804000,
    288288  CL_MULTI_LINE_TEXT            =    0x00000840,
     289  CL_LIMITED_WIDTH_TEXT         =    0x00000841,
    289290
    290291  // Texutres.
     
    362363  CL_GLGUI_TEXTFIELD            =    0x00000b61,
    363364  CL_GLGUI_IMAGE                =    0x00000b70,
     365  CL_GLGUI_TABLE                =    0x00000b71,
    364366
    365367  CL_GLGUI_NOTIFIER             =    0x00000b80,
  • trunk/src/lib/event/event_handler.cc

    r8490 r8619  
    355355  else
    356356  {
    357     SDL_WM_GrabInput(SDL_GRAB_ON);
     357    //SDL_WM_GrabInput(SDL_GRAB_ON);
    358358    SDL_ShowCursor(SDL_DISABLE);
    359359  }
  • trunk/src/lib/graphics/Makefile.am

    r8293 r8619  
    44noinst_LIBRARIES = libORXgraphics.a
    55
    6 libORXgraphics_a_SOURCES = graphics_engine.cc \
    7                            light.cc \
    8                            shader.cc \
    9                            \
    10                            render2D/render_2d.cc \
    11                            render2D/element_2d.cc \
    12                            render2D/image_plane.cc \
    13                            \
    14                            text_engine/text_engine.cc \
    15                            text_engine/text.cc \
    16                            text_engine/multi_line_text.cc \
    17                            text_engine/font.cc \
    18                            \
    19                            effects/graphics_effect.cc \
    20                            effects/atmospheric_engine.cc \
    21                            effects/weather_effect.cc \
    22                            effects/sun_effect.cc \
    23                            effects/fog_effect.cc \
    24                            effects/volfog_effect.cc \
    25                            effects/rain_effect.cc \
    26                            effects/snow_effect.cc \
    27                            effects/cloud_effect.cc \
    28                            effects/lightening_effect.cc \
    29                            effects/lense_flare.cc
     6libORXgraphics_a_SOURCES = \
     7                graphics_engine.cc \
     8                light.cc \
     9                shader.cc \
     10                \
     11                render2D/render_2d.cc \
     12                render2D/element_2d.cc \
     13                render2D/image_plane.cc \
     14                \
     15                text_engine/text_engine.cc \
     16                text_engine/text.cc \
     17                text_engine/multi_line_text.cc \
     18                text_engine/limited_width_text.cc \
     19                text_engine/font.cc \
     20                \
     21                effects/graphics_effect.cc \
     22                effects/atmospheric_engine.cc \
     23                effects/weather_effect.cc \
     24                effects/sun_effect.cc \
     25                effects/fog_effect.cc \
     26                effects/volfog_effect.cc \
     27                effects/rain_effect.cc \
     28                effects/snow_effect.cc \
     29                effects/cloud_effect.cc \
     30                effects/lightening_effect.cc \
     31                effects/lense_flare.cc
    3032
    3133noinst_HEADERS = graphics_engine.h \
     
    4042                 text_engine/text.h \
    4143                 text_engine/multi_line_text.h \
     44                 text_engine/limited_width_text.h \
    4245                 text_engine/font.h \
    4346                 text_engine/default_font.xpm \
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r8495 r8619  
    4747    this->setClassID(CL_LENSE_FLARE, "LenseFlare");
    4848
    49     this->flareMatrix = new float[14];
    5049    /*          length                      image scale */
    5150    this->flareMatrix[0] = 1.0f;
  • trunk/src/lib/graphics/effects/lense_flare.h

    r8495 r8619  
    5151    bool                     bVisible;          //!< Checks visibility
    5252    Light*                   lightSource;        //!< reference to the sun (or primary light source)
    53     std::vector<ImagePlane*>  flares;             //!< the flares array
     53    std::vector<ImagePlane*> flares;             //!< the flares array
    5454
    5555    Vector2D                 flareVector;        //!< the axis to draw the flares on
     
    5757    Vector2D                 screenCenter;       //!< the vector marking the center of the screen
    5858
    59     float*                   flareMatrix;
     59    float                    flareMatrix[14];
    6060    Plane                    frustumPlane;       //!< plane that marks the view frustum
    6161};
  • trunk/src/lib/graphics/importer/material.cc

    r8376 r8619  
    2222#include "debug.h"
    2323#include "compiler.h"
     24
     25#include "loading/load_param.h"
     26
    2427#include "util/loading/resource_manager.h"
    2528
     
    4750}
    4851
     52Material& Material::operator=(const Material& material)
     53{
     54  this->illumModel = material.illumModel;
     55  this->diffuse = material.diffuse;
     56  this->specular = material.specular;
     57  this->ambient = material.ambient;
     58  this->shininess = material.shininess;
     59
     60  this->textures = material.textures;
     61  this->sFactor = material.sFactor;
     62  this->tFactor = material.tFactor;
     63  this->setName(material.getName());
     64
     65  return *this;
     66}
     67
     68
     69
     70void Material::loadParams(const TiXmlElement* root)
     71{
     72  LoadParam(root, "illum", this, Material, setIllum);
     73
     74  LoadParam(root, "diffuse-color", this, Material , setDiffuse);
     75  LoadParam(root, "ambient-color", this, Material , setAmbient);
     76  LoadParam(root, "specular-color", this, Material , setSpecular);
     77  LoadParam(root, "transparency", this, Material , setTransparency);
     78
     79  LoadParam(root, "tex", this, Material, setDiffuseMap);
     80  LoadParam(root, "blendfunc", this, Material, setBlendFuncS)
     81      .defaultValues("ZERO", "ZERO");
     82}
     83
     84
    4985/**
    5086 * @brief deletes a Material
     
    65101
    66102const Material* Material::selectedMaterial = NULL;
    67 
    68 const GLenum Material::glTextureArbs[] =
    69 {
    70   GL_TEXTURE0,
    71   GL_TEXTURE1,
    72   GL_TEXTURE2,
    73   GL_TEXTURE3,
    74   GL_TEXTURE4,
    75   GL_TEXTURE5,
    76   GL_TEXTURE6,
    77   GL_TEXTURE7
    78 };
    79103
    80104
     
    104128 * @brief sets the material with which the following Faces will be painted
    105129 */
    106   bool Material::select() const
     130bool Material::select() const
    107131{
    108132  if (unlikely(this == Material::selectedMaterial))
    109       return true;
    110 
    111 /// !!  HACK !!! FIX THIS IN MODEL ///
     133    return true;
     134
     135  /// !!  HACK !!! FIX THIS IN MODEL ///
    112136  else if (likely(Material::selectedMaterial != NULL))
    113137  {
    114   Material::unselect();
    115 //     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
    116 //     {
    117 //         glActiveTexture(Material::glTextureArbs[i]);
    118 //         glBindTexture(GL_TEXTURE_2D, 0);
    119 //         glDisable(GL_TEXTURE_2D);
    120 //     }
     138    Material::unselect();
     139    //     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     140    //     {
     141    //         glActiveTexture(Material::glTextureArbs[i]);
     142    //         glBindTexture(GL_TEXTURE_2D, 0);
     143    //         glDisable(GL_TEXTURE_2D);
     144    //     }
    121145  }
    122146
     
    125149    for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
    126150    {
    127         glActiveTexture(Material::glTextureArbs[i]);
    128         //glBindTexture(GL_TEXTURE_2D, 0);
    129         glDisable(GL_TEXTURE_2D);
     151      glActiveTexture(Material::glTextureArbs[i]);
     152      //glBindTexture(GL_TEXTURE_2D, 0);
     153      glDisable(GL_TEXTURE_2D);
    130154    }
    131155  }
    132156
    133     // setting diffuse color
     157  // setting diffuse color
    134158  glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a());
    135159  // setting ambient color
     
    161185  for(unsigned int i = 0; i < this->textures.size(); ++i)
    162186  {
    163       glActiveTexture(Material::glTextureArbs[i]);
    164       glEnable(GL_TEXTURE_2D);
    165       if(this->textures[i].hasAlpha())
    166       {
    167         glEnable(GL_BLEND);
    168       }
    169       glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture());
     187    glActiveTexture(Material::glTextureArbs[i]);
     188    glEnable(GL_TEXTURE_2D);
     189    if(this->textures[i].hasAlpha())
     190    {
     191      glEnable(GL_BLEND);
     192    }
     193    glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture());
    170194  }
    171195  Material::selectedMaterial = this;
     
    179203{
    180204  Material::selectedMaterial = NULL;
    181     for(unsigned int i = 0; i < 8; ++i)
    182     {
    183         glActiveTexture(Material::glTextureArbs[i]);
    184         glBindTexture(GL_TEXTURE_2D, 0);
    185         glDisable(GL_TEXTURE_2D);
    186     }
     205  for(unsigned int i = 0; i < 8; ++i)
     206  {
     207    glActiveTexture(Material::glTextureArbs[i]);
     208    glBindTexture(GL_TEXTURE_2D, 0);
     209    glDisable(GL_TEXTURE_2D);
     210  }
    187211}
    188212
     
    252276  this->diffuse.a() = trans;
    253277}
     278
     279/**
     280 * @brief sets the Blend-Function Parameters
     281 * @param sFactor the Source Parameter.
     282 * @param tFactor the Desitnation Parameter.
     283 */
     284void Material::setBlendFuncS(const std::string& sFactor, const std::string& tFactor)
     285{
     286  this->setBlendFunc(Material::stringToBlendFunc(sFactor), Material::stringToBlendFunc(tFactor));
     287}
     288
     289
    254290
    255291/**
     
    354390  // HACK
    355391  glActiveTexture(textureNumber);
    356    glEnable(GL_TEXTURE_2D);
    357    glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture());
     392  glEnable(GL_TEXTURE_2D);
     393  glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture());
    358394  glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
    359395
     
    387423 */
    388424void Material::setBump(const std::string& bump)
    389 {
    390 }
     425{}
    391426
    392427
     
    400435  return maxTexUnits;
    401436}
     437
     438const GLenum Material::glTextureArbs[] =
     439{
     440  GL_TEXTURE0,
     441  GL_TEXTURE1,
     442  GL_TEXTURE2,
     443  GL_TEXTURE3,
     444  GL_TEXTURE4,
     445  GL_TEXTURE5,
     446  GL_TEXTURE6,
     447  GL_TEXTURE7
     448};
     449
     450
     451/**
     452 * @param blendFunc the Enumerator to convert to a String.
     453 * @returns the matching String if found
     454 */
     455const std::string& Material::blendFuncToString(GLenum blendFunc)
     456{
     457  for (unsigned int i = 0; i < 9; ++i)
     458    if (blendFunc == Material::glBlendFuncParams[i])
     459      return Material::blendFuncNames[i];
     460  PRINTF(2)("Supplied an Invalid Enumerator to blendfunc %d\n", blendFunc);
     461  return Material::blendFuncNames[0];
     462}
     463
     464/**
     465 * @param blendFuncString the String to convert into a gl-enumeration
     466 * @returns the matching GL-enumeration if found.
     467 */
     468GLenum Material::stringToBlendFunc(const std::string& blendFuncString)
     469{
     470  for (unsigned int i = 0; i < 9; ++i)
     471    if (blendFuncString == Material::blendFuncNames[i])
     472      return Material::glBlendFuncParams[i];
     473  PRINTF(2)("BlendFunction %s not recognized using %s\n", blendFuncString.c_str(), Material::blendFuncNames[0].c_str());
     474  return Material::glBlendFuncParams[0];
     475}
     476
     477
     478const GLenum Material::glBlendFuncParams[] =
     479  {
     480    GL_ZERO,
     481    GL_ONE,
     482    GL_DST_COLOR,
     483    GL_ONE_MINUS_DST_COLOR,
     484    GL_SRC_ALPHA,
     485    GL_ONE_MINUS_SRC_ALPHA,
     486    GL_DST_ALPHA,
     487    GL_ONE_MINUS_DST_ALPHA,
     488    GL_SRC_ALPHA_SATURATE
     489  };
     490
     491const std::string Material::blendFuncNames[] =
     492  {
     493    "ZERO",
     494    "ONE",
     495    "DST_COLOR",
     496    "ONE_MINUS_DST_COLOR",
     497    "SRC_ALPHA",
     498    "ONE_MINUS_SRC_ALPHA",
     499    "DST_ALPHA",
     500    "ONE_MINUS_DST_ALPHA",
     501    "SRC_ALPHA_SATURATE"
     502
     503  };
  • trunk/src/lib/graphics/importer/material.h

    r8448 r8619  
    2424class Material : public BaseObject
    2525{
    26   public:
    27     Material (const std::string& mtlName = "");
    28     virtual ~Material ();
     26public:
     27  Material (const std::string& mtlName = "");
     28  virtual ~Material ();
    2929
    30     Material& operator=(const Material& material);
     30  void loadParams(const TiXmlElement* root);
    3131
    32     bool select () const;
    33     bool activateTextureUnit(unsigned int textureNumber);
    34     static void unselect();
     32  Material& operator=(const Material& material);
    3533
    36     void setIllum (int illum);
    37     int getIllumModel() const { return this->illumModel; };
     34  bool select () const;
     35  bool activateTextureUnit(unsigned int textureNumber);
     36  static void unselect();
    3837
    39     void setDiffuse (float r, float g, float b);
    40     void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
    41     void setAmbient (float r, float g, float b);
    42     void setSpecular (float r, float g, float b);
    43     void setShininess (float shini);
    44     void setTransparency (float trans);
    45     void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
     38  void setIllum (int illum);
     39  int getIllumModel() const { return this->illumModel; };
    4640
    47     const Color& getDiffuseColor() const { return diffuse; };
     41  void setDiffuse (float r, float g, float b);
     42  void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
     43  void setAmbient (float r, float g, float b);
     44  void setSpecular (float r, float g, float b);
     45  void setShininess (float shini);
     46  void setTransparency (float trans);
     47  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
     48  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
    4849
    49     // MAPPING //
    50     void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
    51     void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    52     void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    53     void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
     50  Color& diffuseColor() { return diffuse; };
     51  const Color& diffuseColor() const { return diffuse; };
    5452
    55     void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
    56     void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
    57     void setBump(const std::string& bump);
    58     GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
     53  // MAPPING //
     54  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
     55  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     56  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     57  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
    5958
    60     static void addTexturePath(const std::string& pathName);
     59  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
     60  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
     61  void setBump(const std::string& bump);
    6162
    62   public:
    63     static const GLenum glTextureArbs[];  //!< The Texture ARB's
     63  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
    6464
    65     static unsigned int getMaxTextureUnits();
     65  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
    6666
    67   private:
    68     static const Material* selectedMaterial; //!< The currently selected material.
     67  static void addTexturePath(const std::string& pathName);
    6968
    70     int              illumModel;       //!< The IlluminationModel is either flat or smooth.
    71     Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
    72     Color            ambient;          //!< The ambient color of the Material.
    73     Color            specular;         //!< The specular color of the Material.
    74     float            shininess;        //!< The shininess of the Material.
    75     GLenum           sFactor;          //!< The Blending Factor for the Source.
    76     GLenum           tFactor;          //!< The Blending Factor for the Destination.
     69  const std::string& blendFuncToString(GLenum blendFunc);
     70  GLenum stringToBlendFunc(const std::string& blendFuncString);
    7771
    78     std::vector<Texture> textures;     //!< An Array of Textures.
    7972
    80     Texture*         ambientTexture;   //!< The ambient texture of the Material.
    81     Texture*         specularTexture;  //!< The specular texture of the Material.
     73public:
     74  static const GLenum glTextureArbs[];  //!< The Texture ARB's
     75
     76  static const GLenum glBlendFuncParams[];
     77  static const std::string blendFuncNames[];
     78
     79  static unsigned int getMaxTextureUnits();
     80
     81private:
     82  static const Material* selectedMaterial; //!< The currently selected material.
     83
     84  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
     85  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
     86  Color            ambient;          //!< The ambient color of the Material.
     87  Color            specular;         //!< The specular color of the Material.
     88  float            shininess;        //!< The shininess of the Material.
     89  GLenum           sFactor;          //!< The Blending Factor for the Source.
     90  GLenum           tFactor;          //!< The Blending Factor for the Destination.
     91
     92  std::vector<Texture> textures;     //!< An Array of Textures.
     93
     94  Texture*         ambientTexture;   //!< The ambient texture of the Material.
     95  Texture*         specularTexture;  //!< The specular texture of the Material.
    8296};
    8397
  • trunk/src/lib/graphics/importer/texture_sequence.cc

    r8324 r8619  
    180180  }
    181181  bool success = this->addFrame(addSurface);
    182   delete addSurface;
     182  SDL_FreeSurface(addSurface);
    183183
    184184  return success;
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r8448 r8619  
    6161void MultiLineText::draw() const
    6262{
    63   if (unlikely(this->getText().empty()))
     63  if (unlikely(this->text().empty()))
    6464    return;
    6565  glPushMatrix();
     
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    78   glColor4fv(&this->getColor()[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->getFont()->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);
     
    9292
    9393  glBegin(GL_QUADS);
    94   for (unsigned int i = 0; i < this->getText().size(); ++i)
     94  for (unsigned int i = 0; i < this->text().size(); ++i)
    9595  {
    9696    if (unlikely(this->lineEnds.size() > lineNumber && i == this->lineEnds[lineNumber]))
     
    9999      ++lineNumber;
    100100      posX = 0.0f;
    101       posY += this->lineSpacing + this->getSize(); //this->getFont()->getMaxHeight();
     101      posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight();
    102102    }
    103103
    104     if(likely((tmpGlyph = this->getFont()->getGlyphArray()[this->getText()[i]]) != NULL))
     104    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL))
    105105    {
    106106      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    107       glVertex2d(posX+tmpGlyph->maxX*this->getSize(), posY);
     107      glVertex2d(posX+tmpGlyph->maxX*this->size(), posY);
    108108
    109109      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    110       glVertex2d(posX+tmpGlyph->maxX*this->getSize(), posY + this->getSize());
     110      glVertex2d(posX+tmpGlyph->maxX*this->size(), posY + this->size());
    111111
    112112      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    113       glVertex2d(posX+tmpGlyph->minX*this->getSize(), posY+ this->getSize());
     113      glVertex2d(posX+tmpGlyph->minX*this->size(), posY+ this->size());
    114114
    115115      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    116       glVertex2d(posX+tmpGlyph->minX*this->getSize(), posY);
     116      glVertex2d(posX+tmpGlyph->minX*this->size(), posY);
    117117
    118       posX += tmpGlyph->advance * this->getSize();
     118      posX += tmpGlyph->advance * this->size();
    119119    }
    120120  }
     
    132132  this->lineEnds.clear();
    133133  float width = 0.0f;
    134   float maxWidth = this->lineWidth / this->getSize();
     134  float maxWidth = this->lineWidth / this->size();
    135135
    136   for (unsigned int i = 0; i < this->getText().size(); i++)
     136  for (unsigned int i = 0; i < this->text().size(); i++)
    137137  {
    138     if (width > maxWidth || this->getText()[i] == '\n')
     138    if (width > maxWidth || this->text()[i] == '\n')
    139139    {
    140140      if (likely(i > 0))
    141141      {
    142142        this->lineEnds.push_back( i -1 );
    143         width = this->getFont()->getGlyphArray()[this->getText()[i-1]]->advance;
     143        width = this->font()->getGlyphArray()[this->text()[i-1]]->advance;
    144144      }
    145145      else
     
    148148
    149149    // Advance the Text.
    150     if(this->getFont()->getGlyphArray()[this->getText()[i]] != NULL)
    151       width += this->getFont()->getGlyphArray()[this->getText()[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->getFont()->getMaxHeight()));
     154  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight()));
    155155}
    156156
     
    162162 printf("Debug %s::%s: %d lines\n", this->getClassName(), this->getName(), this->getLineCount());
    163163
    164  std::string tmpText = this->getText();
     164 std::string tmpText = this->text();
    165165 std::vector<unsigned int> ends = this->lineEnds;
    166166 ends.push_back(tmpText.size());
  • trunk/src/lib/graphics/text_engine/text.cc

    r8518 r8619  
    2222#include "debug.h"
    2323
    24 using namespace std;
    25 
    2624/**
    2725 * @brief creates a new Text Element
     
    3432
    3533  // initialize this Text
    36   this->font = NULL;
    37   this->size = textSize;
    38   this->setSizeY2D(size);
    39   this->color = TEXT_DEFAULT_COLOR;
     34  this->_font = NULL;
     35  this->_size = textSize;
     36  this->setSizeY2D(textSize);
     37  this->_color = TEXT_DEFAULT_COLOR;
    4038
    4139  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
     
    4745{
    4846  this->setClassID(CL_TEXT, "Text");
    49   this->font = NULL;
     47  this->_font = NULL;
    5048
    5149  *this = text;
     
    5856Text::~Text()
    5957{
    60   if (this->font != NULL && this->font != Font::getDefaultFont())
    61     ResourceManager::getInstance()->unload(this->font);
     58  if (this->_font != NULL && this->_font != Font::getDefaultFont())
     59    ResourceManager::getInstance()->unload(this->_font);
    6260}
    6361
     
    6967bool Text::operator==(const Text& text) const
    7068{
    71   return (this->text == text.text &&
    72           this->size == text.size &&
    73           this->font == text.font &&
    74           this->color == text.color);
     69  return (this->_text == text._text &&
     70          this->_size == text._size &&
     71          this->_font == text._font &&
     72          this->_color == text._color);
    7573}
    7674
     
    8280bool Text::operator==(const std::string& text) const
    8381{
    84   return (this->text == text);
     82  return (this->_text == text);
    8583}
    8684
     
    9290Text& Text::operator=(const Text& text)
    9391{
    94   this->size = text.size;
    95   this->color = text.color;
     92  this->_size = text._size;
     93  this->_color = text._color;
    9694  this->setAlignment(text.getAlignment());
    97   if (this->font != NULL)
    98     ResourceManager::getInstance()->unload(this->font);
    99 
    100   this->font = (Font*)ResourceManager::getInstance()->copy( text.font ); //!< HACK
    101 
    102   this->text = text.text;
     95  if (this->_font != NULL)
     96    ResourceManager::getInstance()->unload(this->_font);
     97
     98  this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK
     99
     100  this->_text = text._text;
    103101  return *this;
    104102}
     
    110108void Text::setText(const std::string& text)
    111109{
    112   this->text = text;
     110  this->_text = text;
    113111  this->setupTextWidth();
    114112}
     
    120118void Text::append(const std::string& appendText)
    121119{
    122   this->text += appendText;
     120  this->_text += appendText;
    123121  this->setupTextWidth();
    124122}
     
    129127void Text::appendCharacter(char character)
    130128{
    131   this->text += character;
     129  this->_text += character;
    132130  this->setupTextWidth();
    133131}
     
    141139{
    142140  this->append(appendText);
    143   return this->text;
     141  return this->_text;
    144142}
    145143
     
    152150void Text::removeCharacters(unsigned int chars)
    153151{
    154   if (text.size() > chars)
    155     this->text.resize(this->text.size()-chars);
    156   else if (!text.empty())
    157     text.clear();
     152  if (this->_text.size() > chars)
     153    this->_text.resize(this->_text.size()-chars);
     154  else if (!this->_text.empty())
     155    this->_text.clear();
    158156  this->setupTextWidth();
    159157}
     
    165163void Text::clear()
    166164{
    167   text.clear();
     165  this->_text.clear();
    168166  this->setupTextWidth();
    169167}
     
    177175{
    178176  Font* newFont = NULL;
    179   Font* oldFont = this->font;
     177  Font* oldFont = this->_font;
    180178
    181179  // load a new Font
     
    194192
    195193  // unloading the Font if we alrady have one loaded.
    196   this->font = newFont;
     194  this->_font = newFont;
    197195  if (oldFont != NULL && oldFont != Font::getDefaultFont())
    198196    ResourceManager::getInstance()->unload(oldFont);
     
    207205void Text::setSize(float size)
    208206{
    209   this->size = size;
     207  this->_size = size;
    210208  this->setSizeY2D(size);
    211209  this->setupTextWidth();
     
    218216void Text::draw() const
    219217{
    220   if (unlikely(this->text.empty()))
     218  if (unlikely(this->_text.empty()))
    221219    return;
    222220  glPushMatrix();
     
    230228  // drawing this Text.
    231229  // setting the Blending effects
    232   glColor4fv(&this->color[0]);
     230  glColor4fv(&this->_color[0]);
    233231
    234232
     
    240238  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    241239
    242   glBindTexture(GL_TEXTURE_2D, font->getTexture());
     240  glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
    243241  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    244242  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    247245  float posX = 0.0f;
    248246  glBegin(GL_QUADS);
    249   for (unsigned int i = 0; i < this->text.size(); i++)
     247  for (unsigned int i = 0; i < this->_text.size(); i++)
    250248  {
    251     if(likely((tmpGlyph = this->getFont()->getGlyphArray()[this->text[i]]) != NULL))
     249    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
    252250    {
    253251      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    254       glVertex2d(posX+tmpGlyph->maxX*this->getSize(), 0);
     252      glVertex2d(posX+tmpGlyph->maxX*this->size(), 0);
    255253
    256254      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    257       glVertex2d(posX+tmpGlyph->maxX*this->getSize(), this->getSize());
     255      glVertex2d(posX+tmpGlyph->maxX*this->size(), this->size());
    258256
    259257      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    260       glVertex2d(posX+tmpGlyph->minX*this->getSize(), this->getSize());
     258      glVertex2d(posX+tmpGlyph->minX*this->size(), this->size());
    261259
    262260      glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    263       glVertex2d(posX+tmpGlyph->minX*this->getSize(), 0);
    264 
    265       posX += tmpGlyph->advance * this->getSize();
     261      glVertex2d(posX+tmpGlyph->minX*this->size(), 0);
     262
     263      posX += tmpGlyph->advance * this->size();
    266264    }
    267265  }
     
    278276{
    279277  float width = 0;
    280   for (unsigned int i = 0; i < this->text.size(); i++)
    281     if(this->font->getGlyphArray()[this->text[i]] != NULL)
    282       width += this->font->getGlyphArray()[this->text[i]]->advance;
    283   this->setSizeX2D(width * this->getSize());
     278  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;
     281  this->setSizeX2D(width * this->size());
    284282}
    285283
     
    290288void Text::debug() const
    291289{
    292   PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->font->getName(), this->text.c_str());
    293   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());
    294 }
    295 
     290  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str());
     291  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());
     292}
     293
  • trunk/src/lib/graphics/text_engine/text.h

    r8518 r8619  
    4545    void setFont(const std::string& fontFile, unsigned int renderSize);
    4646    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    47     inline void setBlending(float blending) { this->color.a() = blending; };
     47    inline void setBlending(float blending) { this->_color.a() = blending; };
    4848    /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
    49     void setColor(float r, float g, float b) { this->color = Color(r, g, b, this->color.a()); };
    50     void setColor(float r, float g, float b, float a) { this->color = Color(r, g, b, a); };
    51     void setColor(const Color& color) { this->color = color; };
     49    void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); };
     50    void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); };
     51    void setColor(const Color& color) { this->_color = color; };
    5252    void setSize(float size);
    5353
     
    5555    /// RETRIEVE
    5656    /** @returns the String this Text displays */
    57     inline const std::string& getText() const { return this->text; };
     57    inline const std::string& text() const { return this->_text; };
    5858
    5959    /** @returns the pointer to the stored Font (not changeable) */
    60     inline const Font* const getFont() const { return this->font; };
     60    inline const Font* const font() const { return this->_font; };
    6161    /** @returns the Blending Value [0 invisible 1.0 full visible */
    62     inline float getBlending() const { return this->color.a(); };
     62    inline float blending() const { return this->_color.a(); };
    6363    /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
    64     inline const Color& getColor() const { return this->color; };
     64    inline const Color& color() const { return this->_color; };
    6565    /** @returns the Size of the Text */
    66     inline float getSize() const { return this->size; };
     66    inline float size() const { return this->_size; };
    6767
    6868    virtual void draw() const;
     
    7676
    7777  private:
    78     Font*             font;           //!< Font of this text
     78    Font*             _font;           //!< Font of this text
    7979
    80     std::string       text;           //!< The text to display
    81     Color             color;          //!< The color of the font.
    82     float             size;           //!< The size of the Text.
     80    std::string       _text;           //!< The text to display
     81    Color             _color;          //!< The color of the font.
     82    float             _size;           //!< The size of the Text.
    8383};
    8484
  • trunk/src/lib/gui/gl/Makefile.am

    r8518 r8619  
    1212                glmenu/glmenu_imagescreen.cc \
    1313                \
    14                 glgui_style.cc \
    1514                glgui_handler.cc \
    1615                signal_connector.cc \
     
    2726                glgui_inputline.cc \
    2827                glgui_textfield.cc \
     28                glgui_table.cc \
    2929                glgui_image.cc \
    3030                glgui_window.cc \
     
    3737                glmenu/glmenu_imagescreen.h \
    3838                \
    39                 glgui_style.h \
    4039                signal_connector.h \
    4140                glgui.h \
     
    5453                glgui_inputline.h \
    5554                glgui_textfield.h \
     55                glgui_table.h \
    5656                glgui_image.h \
    5757                glgui_window.h \
  • trunk/src/lib/gui/gl/glgui.h

    r8145 r8619  
    1616#include "glgui_button.h"
    1717#include "glgui_checkbutton.h"
    18 //#include "glgui_colorselector.h"
    1918#include "glgui_pushbutton.h"
    2019#include "glgui_slider.h"
     
    2221#include "glgui_inputline.h"
    2322#include "glgui_textfield.h"
     23#include "glgui_table.h"
    2424#include "glgui_image.h"
    2525
  • trunk/src/lib/gui/gl/glgui_box.cc

    r8450 r8619  
    110110    if (orientation() == OrxGui::Vertical)
    111111    {
    112       float height = this->borderTop();
     112      float height = borderTop();
    113113      float width = 0.0f;
    114114      std::vector<GLGuiWidget*>::iterator widget;
     
    117117      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    118118      {
    119         (*widget)->setRelCoor2D(this->borderLeft(), height);
     119        (*widget)->setRelCoor2D(borderLeft(), height);
    120120        height += (*widget)->getSizeY2D();
    121121        width = fmax(width, (*widget)->getSizeX2D());
    122122      }
    123123
    124       width += this->borderLeft() + this->borderRight();
    125       height += this->borderBottom(); /* *2 done further up */
     124      width += borderLeft() + borderRight();
     125      height += borderBottom(); /* *2 done further up */
    126126
    127127      printf("%f %f\n", width, height);
     
    130130    else
    131131    {
    132       float height = this->borderTop();
    133       float width = this->borderLeft();
     132      float height = borderTop();
     133      float width = borderLeft();
    134134      std::vector<GLGuiWidget*>::iterator widget;
    135135
     
    137137      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    138138      {
    139         (*widget)->setRelCoor2D(width, this->borderTop());
     139        (*widget)->setRelCoor2D(width, borderTop());
    140140        height = fmax(height, (*widget)->getSizeY2D());
    141141        width += (*widget)->getSizeX2D();
    142142      }
    143143
    144       width += this->borderRight() ;
    145       height += this->borderBottom(); /* *2 done further up */
     144      width += borderRight() ;
     145      height += borderBottom(); /* *2 done further up */
    146146
    147147      printf("%f %f\n", width, height);
  • trunk/src/lib/gui/gl/glgui_button.cc

    r8448 r8619  
    5555
    5656    this->_label.setFont("fonts/final_frontier.ttf", 20);
    57     this->_label.setColor(this->frontColor());
     57    this->_label.setColor(this->foregroundColor() );
    5858
    5959    this->_label.setParent2D(this);
     
    7171  void GLGuiButton::updateFrontColor()
    7272  {
    73     this->_label.setColor(this->frontColor());
     73    this->_label.setColor(this->foregroundColor());
    7474  }
    7575
  • trunk/src/lib/gui/gl/glgui_button.h

    r8448 r8619  
    3636      virtual ~GLGuiButton();
    3737
    38       const std::string& label() const { return this->_label.getText(); };
     38      const std::string& label() const { return this->_label.text(); };
    3939      void setLabel(const std::string& label);
    4040
  • trunk/src/lib/gui/gl/glgui_checkbutton.cc

    r8448 r8619  
    9696//     this->frontMaterial().select();
    9797//     this->drawRect(this->frontRect());
    98 
    9998    if (this->bActive)
    10099    {
    101       glColor3fv( &this->frontColor()[0]);
     100      glColor3fv( &this->foregroundColor()[0]);
    102101      this->drawRect(this->_checkBox);
    103102
     
    124123    else
    125124    {
    126       glColor3fv( &this->frontColor()[0]);
     125      glColor3fv( &this->foregroundColor()[0]);
    127126      this->drawRect(this->_checkBox);
    128127    }
  • trunk/src/lib/gui/gl/glgui_container.cc

    r8145 r8619  
    4343    this->setClassID(CL_GLGUI_CONTAINER, "GLGuiContainer");
    4444
     45    this->setBackgroundTexture("gui_container_background.png");
     46
    4547  }
    4648
  • trunk/src/lib/gui/gl/glgui_cursor.cc

    r8324 r8619  
    5757    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
    5858
    59     this->backMaterial().setDiffuse(1.0,0.0,0.0);
    60     this->backMaterial().setDiffuseMap("cursor.png");
    61     this->backMaterial().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     59    this->setBackgroundColor(Color(1.0, 1.0, 1.0, 1.0));
     60    this->setBackgroundTexture("cursor.png");
    6261    this->setSize2D(50, 50);
    6362    this->setAbsCoor2D(100, 100);
    6463    this->setLayer(E2D_LAYER_ABOVE_ALL);
    6564    this->color = 0.0f;
     65    this->frameNumber = 0.0f;
    6666
    6767    this->resize();
     
    7979  bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
    8080  {
    81     this->backMaterial().setDiffuse(1.0, 1.0, 1.0);
     81    //this->background().setDiffuse(1.0, 1.0, 1.0);
    8282    return this->seq.loadImageSeries(imageNameSubstitue, from, to);
    8383  }
     
    9797        this->color -= 360.0;
    9898      Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
    99       this->backMaterial().setDiffuse(color.x, color.y, color.z);
     99      //this->setBackgroundColor(color.x, color.y, color.z);
     100      /// FIXME
     101
    100102    }
    101103    //if (this->movement != Vector2D())
     
    125127    this->beginDraw();
    126128
    127     this->backMaterial().select();
     129    this->background().select();
    128130    if (!this->seq.empty())
    129131      glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber));
  • trunk/src/lib/gui/gl/glgui_defs.h

    r8448 r8619  
    2222  } Orientation;
    2323
     24  //! Names of Orientations
    2425  const std::string OrientationString[] = {
    2526    "Horizontal",
     
    3031  typedef enum {
    3132    Normal,           //!< Normal state of the GUI's Widgets.
    32     Active,           //!< If the widget is Active.
     33    Focused,           //!< If the widget is Active.
    3334    Selected,         //!< If the Widget is Selected.
    3435    Insensitive       //!< If the Widget is insensitive.
     
    3839#define GLGUI_DEFAULT_STYLE OrxGui::Normal
    3940
     41//! names of the States.
    4042  const std::string StateString[] =
    4143    {
    4244      "Normal",
    43       "Active",
     45      "Focused",
    4446      "Selected",
    4547      "Insensitive"
     
    5456    } FeaturePosition;
    5557
     58    //! Names of Feature-Positions
    5659    const std::string FeaturePositionString[] =
    5760    {
  • trunk/src/lib/gui/gl/glgui_image.cc

    r8448 r8619  
    4747    this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage");
    4848
     49    this->setForegroundColor(Color(1,1,1,1));
    4950    this->_imageMaterial.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    5051
     
    7677  void GLGuiImage::updateFrontColor()
    7778  {
    78     this->_imageMaterial.setDiffuseColor(this->frontColor());
     79    this->_imageMaterial.setDiffuseColor(foregroundColor());
    7980  }
    8081
    8182  void GLGuiImage::resize()
    8283  {
    83     this->_imagePlane.setTopLeft(this->borderLeft(), this->borderTop());
     84    this->_imagePlane.setTopLeft(borderLeft(), borderTop());
    8485    this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );
    8586    GLGuiWidget::resize();
  • trunk/src/lib/gui/gl/glgui_inputline.cc

    r8518 r8619  
    5252    this->_text.setRelCoor2D(4,4);
    5353    this->_text.setFont("fonts/final_frontier.ttf", 20);
    54     this->_text.setColor(this->frontColor());
     54    this->_text.setLineWidth(400);
     55    this->_text.setDotsPosition(LimitedWidthText::Begin);
     56    this->_text.setColor(foregroundColor());
    5557    this->_text.setVisibility(false);
    5658    this->resize();
     59
     60    this->delayNext = 0.0;
     61    this->pressedKey = SDLK_FIRST;
     62    this->pressedKeyName = SDLK_FIRST;
    5763
    5864  }
     
    116122    this->resize();
    117123    this->setFrontColor(Color(1,1,1,1), true);
    118     this->setFrontColor(Color(0,1,0,1));
    119     emit(this->textChanged(this->_text.getText()));
     124    emit(this->textChanged(this->_text.text()));
    120125  }
    121126
     
    139144  void GLGuiInputLine::pushEnter()
    140145  {
    141     emit(this->enterPushed(this->_text.getText()));
     146    emit(this->enterPushed(this->_text.text()));
    142147    if (this->_clearOnEnter)
    143148      this->clear();
     
    197202  void GLGuiInputLine::resize()
    198203  {
    199     this->_text.setRelCoor2D(this->borderLeft(), this->borderTop());
     204    this->_text.setRelCoor2D(borderLeft(), borderTop());
    200205    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
    201206    GLGuiWidget::resize();
    202 /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
    203     this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
     207    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     208        this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
    204209  }
    205210
    206211  void GLGuiInputLine::updateFrontColor()
    207212  {
    208     this->_text.setColor(this->frontColor());
     213    this->_text.setColor(foregroundColor());
    209214  }
    210215
     
    228233    if (this->delayNext > 0.0)
    229234      this->delayNext -= dt;
    230         else if (this->pressedKey != SDLK_FIRST )
     235    else if (this->pressedKey != SDLK_FIRST )
    231236    {
    232237      this->delayNext = GLGuiInputLine::repeatRate;
     
    237242          break;
    238243        default:
    239         {
    240           if (likely(this->pressedKey < 127))
    241             this->appendCharacter(this->pressedKeyName);
    242         }
     244          {
     245            if (likely(this->pressedKey < 127))
     246              this->appendCharacter(this->pressedKeyName);
     247          }
    243248      }
    244249    }
     
    255260    GLGuiWidget::draw();
    256261
    257 //     this->frontMaterial().select();
    258 //     GLGuiWidget::drawRect(this->frontRect());
     262    //     this->frontMaterial().select();
     263    //     GLGuiWidget::drawRect(this->frontRect());
    259264
    260265    this->endDraw();
  • trunk/src/lib/gui/gl/glgui_inputline.h

    r8518 r8619  
    99
    1010#include "glgui_widget.h"
    11 #include "text.h"
     11#include "limited_width_text.h"
    1212#include "event.h"
    1313
     
    3232
    3333    /** @returns the text of the inputLine */
    34     const std::string& _getText() const { return this->_text.getText(); };
     34    const std::string& _getText() const { return this->_text.text(); };
    3535
    3636    void setText(const std::string& text);
     
    6666
    6767  private:
    68     Text                    _text;            //!< The Text to display inside of the InputLine.
     68    LimitedWidthText        _text;            //!< The Text to display inside of the InputLine.
    6969    bool                    _clearOnEnter;    //!< Clear on Enter
    7070
  • trunk/src/lib/gui/gl/glgui_slider.cc

    r8448 r8619  
    7474    else
    7575      this->_value = value;
    76     this->_handle.setCenter(this->sliderPosition(), this->borderTop() + (this->getSizeY2D() - this->borderTop() - borderBottom()) / 2.0);
     76    this->_handle.setCenter(this->sliderPosition(), borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0);
    7777
    7878    emit(valueChanged(this->_value));
     
    165165//    this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0);
    166166//    this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0);
    167     this->_slider.setTopLeft(this->borderLeft(), this->getSizeY2D() / 2.0 -2.0);
     167    this->_slider.setTopLeft(borderLeft(), this->getSizeY2D() / 2.0 -2.0);
    168168    this->_slider.setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0);
    169169    this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - borderTop() - borderBottom());
     
    211211  {
    212212    return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) *
    213            (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) +
    214            (borderLeft() +_sliderWidth);
     213        (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) +
     214        (borderLeft() +_sliderWidth);
    215215  }
    216216
     
    239239    GLGuiWidget::draw();
    240240
    241     glColor4fv(&this->frontColor()[0]);
     241    glColor4fv(&this->foregroundColor()[0]);
    242242    this->drawRect(this->_slider);
    243243    this->drawRect(this->_handle);
  • trunk/src/lib/gui/gl/glgui_widget.cc

    r8448 r8619  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
     16#define DEBUG_SPECIAL_MODULE 4//DEBUG_MODULE_GUI
    1717
    1818#include "glgui_widget.h"
     
    2323
    2424#include "debug.h"
     25
     26#include "loading/load_param.h"
    2527
    2628namespace OrxGui
     
    3941
    4042  /**
     43   * @brief loads Parameters for a Style from XML
     44   * @param root the XML-Element to load from.
     45   */
     46  void GLGuiWidget::loadParams(const TiXmlElement* root)
     47  {
     48
     49    /// STYLE
     50    LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);
     51    LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);
     52    LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);
     53    LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);
     54
     55    LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);
     56    LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);
     57    LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);
     58
     59    //    LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);
     60    //    LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);
     61
     62    LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);
     63    LoadParam(root, "Font", this, GLGuiWidget, setFont);
     64
     65    LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);
     66  }
     67
     68
     69  /**
    4170   * @brief standard deconstructor
    4271   */
     
    4574    if (this == GLGuiWidget::_focused)
    4675      GLGuiWidget::_focused = NULL;
    47 
    48     if (this->_toFrontColor)
    49       delete this->_toFrontColor;
    5076  }
    5177
     
    6692    this->_clickable = false;
    6793    this->_pushed = false;
     94    this->_state = OrxGui::Normal;
     95
     96
     97    this->_font = NULL;
     98    this->resetStyle();
     99
     100    this->_animating = false;
     101    this->_animationCycle = 0.0;
     102    this->_animationDuration = 1.0;
     103
     104
     105    this->setBackgroundColor(Color(.51, .3, .3, .5));
     106    this->setBackgroundColor(Color(.3, .5, .3, 1), OrxGui::Selected);
     107    this->_style[0]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     108    this->_style[1]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     109    this->_style[2]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     110    this->_style[3]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     111
     112    this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal);
     113    this->setForegroundColor(Color(0, 0, 1, 1), OrxGui::Selected);
     114    this->setForegroundColor(Color(0, 1, 0, 1), OrxGui::Focused);
     115    this->setForegroundColor(Color(.1, .1, .1, 1), OrxGui::Insensitive);
    68116
    69117    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    70118
    71     this->_backMat.setDiffuseColor(Color(1.0, 0.5, 0.4, 1.0));
    72     this->_backMat.setDiffuseMap("gui_element_background.png");
    73     this->_frontColor = Color(1.0, 0.0, 0.0);
    74     this->_toFrontColor = NULL;
    75 
    76 
    77     this->_borderLeft = 15.0;
    78     this->_borderRight = 1.0;
    79     this->_borderTop = 1.0;
    80     this->_borderBottom = 1.0;
     119    this->setBorderLeft(15);
     120    this->setBackgroundTexture("gui_element_background.png");
     121
     122    this->switchState(_state);
     123    this->_currentStyle = this->_style[_state];
    81124  }
    82125
     
    121164  }
    122165
     166
     167
    123168  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
    124169  {
    125     if (instantaniously)
    126     {
    127       this->_frontColor = frontColor;
    128       if (this->_toFrontColor != NULL)
    129       {
    130         delete this->_toFrontColor;
    131         this->_toFrontColor = NULL;
    132       }
    133     }
    134     else if (!this->_toFrontColor)
    135       this->_toFrontColor = new Color(frontColor);
    136     else
    137       *this->_toFrontColor = frontColor;
    138     //this->_frontColor = frontColor;
    139     //this->updateFrontColor();
     170    this->_currentStyle._foreground.setDiffuseColor(frontColor);
     171    this->animateBack();
    140172  };
    141 
    142 
    143   void GLGuiWidget::setBorderSize(float borderSize)
    144   {
    145     this->_borderLeft = borderSize;
    146     this->_borderRight = borderSize;
    147     this->_borderTop = borderSize;
    148     this->_borderBottom = borderSize;
    149     this->resize();
    150   }
    151 
    152   void GLGuiWidget::setBorderLeft(float borderLeft)
    153   {
    154     this->_borderLeft = borderLeft;
    155     this->resize();
    156   }
    157   void GLGuiWidget::setBorderRight(float borderRight)
    158   {
    159     this->_borderRight = borderRight;
    160     this->resize();
    161   }
    162   void GLGuiWidget::setBorderTop(float borderTop)
    163   {
    164     this->_borderTop = borderTop;
    165     this->resize();
    166   }
    167   void GLGuiWidget::setBorderBottom(float borderBottom)
    168   {
    169     this->_borderBottom = borderBottom;
    170     this->resize();
    171   }
    172 
    173173
    174174
     
    201201  void GLGuiWidget::clicking(const Vector2D& pos)
    202202  {
    203     this->setFrontColor(Color(0, 0, 1));
    204 
     203    this->switchState(OrxGui::Selected);
    205204  }
    206205
    207206  void GLGuiWidget::releasing(const Vector2D& pos)
    208207  {
    209     this->setFrontColor(Color(0,1,0));
    210 
     208    this->switchState(OrxGui::Normal);
    211209  }
    212210
    213211  void GLGuiWidget::receivedFocus()
    214212  {
    215     this->setFrontColor(Color(0, 1, 0));
     213    this->switchState(OrxGui::Focused);
    216214  }
    217215
    218216  void GLGuiWidget::removedFocus()
    219217  {
    220     this->setFrontColor(Color(1, 0, 0));
     218    this->switchState(OrxGui::Normal);
    221219
    222220  }
     
    267265  }
    268266
    269   void GLGuiWidget::tick(float dt)
    270   {
    271     if (this->_toFrontColor)
     267
     268  /**
     269   * @brief resets the Style to the default Settings.
     270   */
     271  void GLGuiWidget::resetStyle()
     272  {
     273    this->setBorderLeft(1.0);
     274    this->setBorderRight(1.0);
     275    this->setBorderTop(1.0);
     276    this->setBorderBottom(1.0);
     277
     278    this->setTextSize(20.0);
     279    this->setBackgroundColor(1.0);
     280    this->setForegroundColor(1.0);
     281
     282    this->setFeaturePosition(FeatureLeft);
     283    this->setFont(NULL);
     284
     285    this->setAnimatedStateChanges(true);
     286  }
     287
     288
     289  /**
     290   * @brief sets the Width of the left border for all States
     291   * @param value the borderWidth
     292   */
     293  void GLGuiWidget::setBorderLeft(float value)
     294  {
     295    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     296      setBorderLeft(value, (OrxGui::State)i);
     297  }
     298
     299  /**
     300   * @brief sets the Width of the left border.
     301   * @param value the borderWidth
     302   * @param state the State to set the borderwidth to
     303   */
     304  void GLGuiWidget::setBorderLeft(float value, OrxGui::State state)
     305  {
     306    _style[state]._borderLeft = value;
     307    if (state == _state)
     308      _currentStyle._borderLeft = value;
     309  }
     310
     311  /**
     312   * @brief sets the Width of the left border.
     313   * @param value the borderWidth
     314   * @param stateName the State to set the borderwidth to
     315   */
     316  void GLGuiWidget::setBorderLeftS(float value, const std::string& stateName)
     317  {
     318    OrxGui::State state;
     319    if (getState(stateName, &state))
     320      this->setBorderLeft(value, state);
     321    else
     322      this->setBorderLeft(value);
     323  }
     324
     325  /**
     326   * @brief sets the Width of the right border for all states.
     327   * @param value the borderWidth
     328   */
     329  void GLGuiWidget::setBorderRight(float value)
     330  {
     331    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     332      setBorderRight(value, (OrxGui::State)i);
     333  }
     334
     335  /**
     336   * @brief sets the Width of the right border.
     337   * @param value the borderWidth
     338   * @param state the State to setup.
     339   */
     340  void GLGuiWidget::setBorderRight(float value, OrxGui::State state)
     341  {
     342    _style[state]._borderRight = value;
     343    if (state == _state)
     344      _currentStyle._borderRight = value;
     345  }
     346
     347  /**
     348   * @brief sets the Width of the right border.
     349   * @param value the borderWidth
     350   * @param stateName the State to setup.
     351   */
     352  void GLGuiWidget::setBorderRightS(float value, const std::string& stateName)
     353  {
     354    OrxGui::State state;
     355    if (getState(stateName, &state))
     356      this->setBorderRight(value, state);
     357    else
     358      this->setBorderRight(value);
     359  }
     360
     361
     362  /**
     363   * @brief sets the Width of the top border for all states.
     364   * @param value the borderWidth
     365   */
     366  void GLGuiWidget::setBorderTop(float value)
     367  {
     368    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     369      setBorderTop(value, (OrxGui::State)i);
     370  }
     371
     372  /**
     373   * @brief sets the Width of the top border.
     374   * @param value the borderWidth
     375   * @param state the State to setup.
     376   */
     377  void GLGuiWidget::setBorderTop(float value, OrxGui::State state)
     378  {
     379    _style[state]._borderTop = value;
     380    if (state == _state)
     381      _currentStyle._borderTop = value;
     382  }
     383
     384  /**
     385   * @brief sets the Width of the top border.
     386   * @param value the borderWidth
     387   * @param stateName the State to setup.
     388   */
     389  void GLGuiWidget::setBorderTopS(float value, const std::string& stateName)
     390  {
     391    OrxGui::State state;
     392    if (getState(stateName, &state))
     393      this->setBorderTop(value, state);
     394    else
     395      this->setBorderTop(value);
     396  }
     397
     398
     399  /**
     400   * @brief sets the Width of the bottom border for all states.
     401   * @param value the borderWidth
     402   */
     403  void GLGuiWidget::setBorderBottom(float value)
     404  {
     405    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     406      setBorderBottom(value, (OrxGui::State)i);
     407  }
     408
     409  /**
     410   * @brief sets the Width of the bottom border.
     411   * @param value the borderWidth
     412   * @param state the State to setup.
     413   */
     414  void GLGuiWidget::setBorderBottom(float value, OrxGui::State state)
     415  {
     416    _style[state]._borderBottom = value;
     417    if (state == _state)
     418      _currentStyle._borderBottom = value;
     419
     420  }
     421
     422  /**
     423   * @brief sets the Width of the bottom border for all states.
     424   * @param value the borderWidth
     425   * @param stateName the State to setup.
     426   */
     427  void GLGuiWidget::setBorderBottomS(float value, const std::string& stateName)
     428  {
     429    OrxGui::State state;
     430    if (getState(stateName, &state))
     431      this->setBorderBottom(value, state);
     432    else
     433      this->setBorderBottom(value);
     434  }
     435
     436
     437  /**
     438   * @brief sets the TextSize for all states.
     439   * @param value the TextSize
     440   */
     441  void GLGuiWidget::setTextSize(float value)
     442  {
     443    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     444      setTextSize(value, (OrxGui::State)i);
     445  }
     446
     447  /**
     448   * @brief sets the TextSize.
     449   * @param value the TextSize.
     450   * @param state: the State to setup
     451   */
     452  void GLGuiWidget::setTextSize(float value, OrxGui::State state)
     453  {
     454    _style[state]._textSize = value;
     455    if (state == _state)
     456      _currentStyle._textSize = value;
     457  }
     458
     459  /**
     460   * @brief sets the TextSize.
     461   * @param value the TextSize.
     462   * @param stateName: the State to setup
     463   */
     464  void GLGuiWidget::setTextSizeS(float value, const std::string& stateName)
     465  {
     466    OrxGui::State state;
     467    if (getState(stateName, &state))
     468      this->setTextSize(value, state);
     469    else
     470      this->setTextSize(value);
     471  }
     472
     473
     474  /**
     475   * @brief sets the Background Color for all States.
     476   * @param color the Color.
     477   */
     478  void GLGuiWidget::setBackgroundColor(const Color& color)
     479  {
     480    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     481      setBackgroundColor(color, (OrxGui::State)i);
     482  }
     483
     484  /**
     485   * @brief sets the Background Color.
     486   * @param color the Color.
     487   * @param state: the State to setup
     488   */
     489  void GLGuiWidget::setBackgroundColor(const Color& color, OrxGui::State state)
     490  {
     491    _style[state]._background.setDiffuseColor(color);
     492    if (state == _state)
     493      _currentStyle._background.setDiffuseColor(color);
     494
     495  }
     496
     497  /**
     498   * @brief sets the Background Color.
     499   * @param r the Color's red part.
     500   * @param g the Color's green part.
     501   * @param b the Color's blue part.
     502   * @param a the Color's alpha part.
     503   * @param stateName: the State to setup
     504   */
     505  void GLGuiWidget::setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName)
     506  {
     507    OrxGui::State state;
     508    if (getState(stateName, &state))
     509      this->setBackgroundColor(Color(r,g,b,a), state);
     510    else
     511      this->setBackgroundColor(Color(r,g,b,a));
     512  }
     513
     514
     515  /**
     516   * @brief sets the Background Texture for all States.
     517   * @param texture the Texture.
     518   */
     519  void GLGuiWidget::setBackgroundTexture(const Texture& texture)
     520  {
     521    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     522      setBackgroundTexture(texture, (OrxGui::State)i);
     523  }
     524
     525  /**
     526  * @brief sets the Background Texture to all States.
     527  * @param textureName the Texture's fileName.
     528   */
     529  void GLGuiWidget::setBackgroundTexture(const std::string& textureName)
     530  {
     531    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     532      _style[i]._background.setDiffuseMap(textureName);
     533    this->_currentStyle._background.setDiffuseMap(textureName);
     534  }
     535
     536  /**
     537   * @brief sets the Background Texture.
     538   * @param texture the Texture.
     539   * @param state the State to setup.
     540   */
     541  void GLGuiWidget::setBackgroundTexture(const Texture& texture, OrxGui::State state)
     542  {
     543    _style[state]._background.setDiffuseMap(texture);
     544    if (state == _state)
     545      _currentStyle._background.setDiffuseMap(texture);
     546  }
     547
     548
     549
     550  /**
     551   * @brief sets the Background Texture.
     552   * @param texture the Texture.
     553   * @param stateName the State to setup.
     554   */
     555  void GLGuiWidget::setBackgroundTexture(const std::string& textureName, const std::string& stateName)
     556  {
     557    OrxGui::State state;
     558    if (getState(stateName, &state))
     559      ; /// FIXME this->setBackgroundTexture(textureName, state);
     560    else
     561      ; ///    this->setBackgroundTexture(textureName);
     562  }
     563
     564
     565  /**
     566   * @brief sets the Foreground Color for all States.
     567   * @param color the Color.
     568   */
     569  void GLGuiWidget::setForegroundColor(const Color& color)
     570  {
     571    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     572      setForegroundColor(color, (OrxGui::State)i);
     573  }
     574
     575  /**
     576   * @brief sets the Foreground Color.
     577   * @param color the Color.
     578   * @param state the State to setup
     579   */
     580  void GLGuiWidget::setForegroundColor(const Color& color, OrxGui::State state)
     581  {
     582    _style[state]._foreground.setDiffuseColor(color);
     583    if (state == _state)
     584      _currentStyle._foreground.setDiffuseColor(color);
     585
     586  }
     587
     588  /**
     589   * @brief sets the Foreground Color.
     590   * @param r the Color's red part.
     591   * @param g the Color's green part.
     592   * @param b the Color's blue part.
     593   * @param a the Color's alpha part.
     594   * @param stateName: the State to setup
     595   */
     596  void GLGuiWidget::setForegroundColorS(float r, float g, float b, float a, const std::string& stateName)
     597  {
     598    OrxGui::State state;
     599    if (getState(stateName, &state))
     600      this->setForegroundColor(Color(r,g,b,a), state);
     601    else
     602      this->setForegroundColor(Color(r,g,b,a));
     603  }
     604
     605
     606  void GLGuiWidget::loadBackgroundMaterial(const Material& material)
     607  {
     608    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     609      this->loadForegroundMaterial(material, (OrxGui::State)i);
     610  }
     611
     612  void GLGuiWidget::loadBackgroundMaterial(const Material& material, OrxGui::State state)
     613  {
     614    this->_style[state]._background = material;
     615    if (state == _state)
     616      _currentStyle._background = material;
     617
     618  }
     619
     620  void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element)
     621  {
     622    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     623      this->loadBackgroundMaterial(element, (OrxGui::State)i);
     624  }
     625
     626  void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state)
     627  {
     628    this->_style[state]._background.loadParams(element);
     629    if (state == _state)
     630      this->_currentStyle._background = _style[state]._background;
     631  }
     632
     633  void GLGuiWidget::loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName)
     634  {
     635    OrxGui::State state;
     636    if (getState(stateName, &state))
     637      this->loadBackgroundMaterial(element, state);
     638    else
     639      this->loadBackgroundMaterial(element);
     640  }
     641
     642  void GLGuiWidget::loadForegroundMaterial(const Material& material)
     643{}
     644  void GLGuiWidget::loadForegroundMaterial(const Material& material, OrxGui::State state)
     645  {}
     646  void GLGuiWidget::loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state)
     647  {}
     648  void GLGuiWidget::loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName)
     649  {}
     650
     651
     652  /**
     653   * @brief sets the Feature-Position.
     654   * @param featurePosition the Feature-Position.
     655   */
     656  void GLGuiWidget::setFeaturePosition(FeaturePosition featurePosition)
     657  {
     658    this->_featurePosition = featurePosition;
     659  }
     660
     661  /**
     662   * @brief sets the Feature-Position by converting from a String.
     663   * @param featurePosition the Feature-Position.
     664   */
     665  void GLGuiWidget::setFeaturePositionS(const std::string& featurePosition)
     666  {
     667    for (unsigned int i = 0; i < 4; ++i)
    272668    {
    273       this->_frontColor.slerp(*_toFrontColor, dt*3.0);
    274       this->updateFrontColor();
    275       if (this->_frontColor.dist(*_toFrontColor) < .1)
     669      if (featurePosition == FeaturePositionString[i])
    276670      {
    277         delete _toFrontColor;
    278         _toFrontColor = NULL;
     671        this->setFeaturePosition((FeaturePosition)i);
    279672      }
    280673    }
    281674  }
    282675
     676  /**
     677   * @brief sets the Font.
     678   * @param font the Font.
     679   */
     680  void GLGuiWidget::setFont(Font* font)
     681  {
     682    this->_font = font;
     683  }
     684
     685  /**
     686   * @brief sets the font from a Font-Name.
     687   * @param fontName the FileName of the Font.
     688   */
     689  void GLGuiWidget::setFont(const std::string& fontName)
     690  {
     691    //this->font = new Font(fontName);
     692  }
     693
     694  /**
     695   * @brief sets the AnimatedState.
     696   * @param animated: it states-changes should animate true, otherwise false.
     697   */
     698  void GLGuiWidget::setAnimatedStateChanges(bool animated)
     699  {
     700    this->_animatedStateChanges = animated;
     701  }
     702
     703
     704  void GLGuiWidget::switchState(OrxGui::State state)
     705  {
     706    //this->_currentStyle = this->_style[state];
     707    this->_state = state;
     708    PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
     709
     710    this->animateBack();
     711  }
     712
     713
     714  void GLGuiWidget::animateBack()
     715  {
     716    this->_animating = true;
     717    this->_animationCycle = 0.0f;
     718  }
     719
     720
     721  void GLGuiWidget::tick(float dt)
     722  {
     723    if (this->_animating)
     724    {
     725      this->foregroundColor();
     726
     727      _animationCycle += dt / _animationDuration;
     728      if (_animationCycle >= 1.0)
     729      {
     730        _currentStyle._foreground.diffuseColor() = this->foregroundColor(_state);
     731        _currentStyle._background.diffuseColor() = this->backgroundColor(_state);
     732        _animating = false;
     733      }
     734      else
     735      {
     736        _currentStyle._foreground.diffuseColor().slerp(this->foregroundColor(_state), _animationCycle);
     737        _currentStyle._background.diffuseColor().slerp(this->backgroundColor(_state), _animationCycle);
     738      }
     739      this->updateFrontColor();
     740    }
     741  }
     742
    283743
    284744  /**
     
    287747  void GLGuiWidget::draw() const
    288748  {
    289     this->backMaterial().select();
     749    this->background().select();
    290750    this->drawRect(this->backRect());
    291     this->backMaterial().unselect();
    292   }
     751    this->background().unselect();
     752  }
     753
     754
     755  /**
     756   * @param stateName the Name of a State.
     757   * @param state the found State is returned here if found.
     758   * @returns true if String is found, false otherwise.
     759   */
     760  bool GLGuiWidget::getState(const std::string& stateName, OrxGui::State* state)
     761  {
     762    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     763      if (stateName == OrxGui::StateString[i])
     764    {
     765      *state = (OrxGui::State)i;
     766      return true;
     767    }
     768    return false;
     769  }
     770
     771  /**
     772   * @brief print out some nice debug output about the Widget.
     773   */
     774  void GLGuiWidget::debug() const
     775  {
     776    PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
     777    if (_parent != NULL)
     778      PRINT(0)("- Parent %s::%s ", _parent->getClassName(), _parent->getName());
     779    PRINT(0)("- State: %s", StateString[_state].c_str());
     780
     781    if (_focusable)
     782      PRINT(0)("- focusable ");
     783    if (_clickable)
     784      PRINT(0)("- Clickable ");
     785    if (_pushed)
     786      PRINT(0)("- Pushed ");
     787    PRINT(0)("\n");
     788
     789
     790    PRINT(0)("Minimum Size %0.2f %0.2f ", _minSize.x, _minSize.y);
     791    PRINT(0)("Back Rect: ");
     792    _backRect.debug();
     793    PRINT(0)("Style:\n");
     794
     795    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     796    {
     797      PRINT(0)("In State %s: \n", StateString[i].c_str());
     798
     799      PRINT(0)("  Borders: Left: %0.2f, Right: %0.2f, Top: %0.2f, Bottom %0.2f\n",
     800               _style[i]._borderLeft, _style[i]._borderRight, _style[i]._borderTop, _style[i]._borderBottom);
     801      PRINT(0)("  TextSize %0.2f\n", _style[i]._textSize);
     802      PRINT(0)("  BackgroundColor: "); _style[i]._background.diffuseColor().debug();
     803      PRINT(0)("  ForegroundColor: "); _style[i]._foreground.diffuseColor().debug();
     804      PRINT(0)("\n");
     805    }
     806
     807
     808    PRINT(0)(" Feature at %s ", FeaturePositionString[_featurePosition].c_str());
     809    /// TODO    PRINT(0)("");    Font*               _font;                 //!< The Font used in the current Widget.
     810
     811    if (_animatedStateChanges)
     812      PRINT(0)("- AnimatedStateChanges");
     813    PRINT(0)("\n");
     814
     815    /*
     816    if (_animating)
     817      PRINT(0)("- Animated ");
     818
     819    //
     820    float               _animationCycle;
     821    float               _animationDuration;
     822    StatedStyle         _currentStyle;
     823    OrxGui::State       _currentState;
     824    */
     825  }
     826
    293827
    294828}
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8518 r8619  
    99#include "element_2d.h"
    1010
    11 #include "glgui_style.h"
     11#include "glgui_defs.h"
     12
    1213#include "material.h"
    1314#include "rect2D.h"
     
    1516#include "event.h"
    1617#include "signal_connector.h"
     18
     19class Font;
    1720
    1821namespace OrxGui
     
    6669    void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver);
    6770
    68 
    69     GLGuiStyle& style() { return this->_style; };
    70     const GLGuiStyle style() const { return this->_style; };
    71 
    72     /// MATERIAL (looks)
    73     Material& backMaterial() { return this->_backMat; };
    74     const Material& backMaterial() const { return this->_backMat; };
     71    OrxGui::State state() const { return this->_state; };
     72
    7573    Rect2D& backRect() { return this->_backRect; };
    7674    const Rect2D& backRect() const { return this->_backRect; };
    7775
    7876    void setFrontColor(const Color& frontColor, bool instantaniously = false);
    79     const Color& frontColor() const { return this->_frontColor; };
    80 
    81     /** @brief sets all borders to the same value. */
    82     void setBorderSize(float borderSize);
    83     void setBorderLeft(float borderLeft);
    84     void setBorderRight(float borderRight);
    85     void setBorderTop(float borderTop);
    86     void setBorderBottom(float borderBottom);
    87 
    88     float borderLeft() const { return this->_borderLeft; };
    89     float borderRight() const { return this->_borderRight; };
    90     float borderTop() const { return this->_borderTop; };
    91     float borderBottom() const { return this->_borderBottom; };
    92 
    9377
    9478    void setWidgetSize(const Vector2D& size);
    9579    void setWidgetSize(float x, float y);
    9680
    97 
    98     void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); };
     81    void animateBack();
     82
     83    /// STYLE
     84    ////////////////////////////////
     85    /// Retrieve Current Values. ///
     86    ////////////////////////////////
     87    /** @returns current left borderWidth */
     88    inline float borderLeft() const { return _currentStyle._borderLeft; }
     89    /** @returns current right borderWidth */
     90    inline float borderRight() const { return _currentStyle._borderRight; }
     91    /** @returns current top borderWidth */
     92    inline float borderTop() const { return _currentStyle._borderTop; }
     93    /** @returns burrent bottom borderWidth */
     94    inline float borderBottom() const { return _currentStyle._borderBottom; }
     95
     96
     97    /** @returns current textSize */
     98    inline float textSize() const { return _currentStyle._textSize; }
     99    /** @returns the Background Color */
     100    inline const Color& backgroundColor() const { return _currentStyle._background.diffuseColor(); }
     101    /** @returns the current Background Material. */
     102    inline const Material& background() const { return _currentStyle._background; }
     103    /** @returns the current background Texture. */
     104    inline const Texture& backgroundTexture() const { return _currentStyle._background.diffuseTexture(); }
     105    /** @returns the current foreground Color */
     106    inline const Color& foregroundColor() const { return _currentStyle._foreground.diffuseColor(); }
     107    /** @returns the current ForeGroung Material. */
     108    inline const Material& foreground() const { return _currentStyle._foreground; }
     109
     110
     111    /** @returns FeaturePosition */
     112    inline FeaturePosition featurePosition() const { return _featurePosition; }
     113    /** @returns the font */
     114    inline const Font* const font() const { return _font; }
     115    /** @returns true if the Element is Animated */
     116    inline bool animating() const { return _animating; }
     117    /** @returns true if State-Changes are animated */
     118    inline bool animatedStateChanges() const { return _animatedStateChanges; }
     119
     120
     121    ///////////////////////////////////////////////////////////////
     122    /// Retrieve Values for the Saved Values inside the States. ///
     123    ///////////////////////////////////////////////////////////////
     124    /** @returns left borderWidth @param state the State to retrieve from */
     125    inline float borderLeft(OrxGui::State state) const { return _style[state]._borderLeft; }
     126    /** @returns right borderWidth @param state the State to retrieve from */
     127    inline float borderRight(OrxGui::State state) const { return _style[state]._borderRight; }
     128    /** @returns top borderWidth @param state the State to retrieve from */
     129    inline float borderTop(OrxGui::State state) const { return _style[state]._borderTop; }
     130    /** @returns bottom borderWidth @param state the State to retrieve from */
     131    inline float borderBottom(OrxGui::State state) const { return _style[state]._borderBottom; }
     132
     133    /** @returns textSize @param state the State to retrieve from */
     134    inline float textSize(OrxGui::State state) const { return _style[state]._textSize; }
     135    /** @returns the Background Color @param state the State to retrieve from */
     136    inline const Color& backgroundColor(OrxGui::State state) const { return _style[state]._background.diffuseColor(); }
     137    /** @returns the Background Material. @param state the state to retrieve from */
     138    inline const Material& background(OrxGui::State state) const { return _style[state]._background; }
     139    /** @returns background Texture. @param state the State to retrieve from */
     140    inline const Texture& backgroundTexture(OrxGui::State state) const { return _style[state]._background.diffuseTexture(); }
     141    /** @returns the foreground Color @param state the State to retrieve from */
     142    inline const Color& foregroundColor(OrxGui::State state) const { return _style[state]._foreground.diffuseColor(); }
     143    /** @returns the ForeGroung Material. @param state the state to retrieve from */
     144    inline const Material& foreground(OrxGui::State state) const { return _style[state]._foreground; }
     145
     146
     147    /// SETUP
     148    void resetStyle();
     149    void loadParams(const TiXmlElement* root);
     150
     151    void setBorderLeft(float value);
     152    void setBorderLeft(float value, OrxGui::State state);
     153    void setBorderLeftS(float value, const std::string& stateName);
     154
     155    void setBorderRight(float value);
     156    void setBorderRight(float value, OrxGui::State state);
     157    void setBorderRightS(float value, const std::string& stateName);
     158
     159    void setBorderTop(float value);
     160    void setBorderTop(float value, OrxGui::State state);
     161    void setBorderTopS(float value, const std::string& stateName);
     162
     163    void setBorderBottom(float value);
     164    void setBorderBottom(float value, OrxGui::State state);
     165    void setBorderBottomS(float value, const std::string& stateName);
     166
     167    void setTextSize(float value);
     168    void setTextSize(float value, OrxGui::State state);
     169    void setTextSizeS(float value, const std::string& stateName);
     170
     171    void setBackgroundColor(const Color& color);
     172    void setBackgroundColor(const Color& color, OrxGui::State state);
     173    void setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName);
     174
     175    void setBackgroundTexture(const Texture& texture);
     176    void setBackgroundTexture(const std::string& textureName);
     177    void setBackgroundTexture(const Texture& texture, OrxGui::State state);
     178    void setBackgroundTexture(const std::string& textureName, const std::string& stateName);
     179
     180    void setForegroundColor(const Color& color);
     181    void setForegroundColor(const Color& color, OrxGui::State state);
     182    void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName);
     183
     184    void loadBackgroundMaterial(const Material& material);
     185    void loadBackgroundMaterial(const Material& material, OrxGui::State state);
     186    void loadBackgroundMaterial(const TiXmlElement* element);
     187    void loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state);
     188    void loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName);
     189
     190    void loadForegroundMaterial(const Material& material);
     191    void loadForegroundMaterial(const Material& material, OrxGui::State state);
     192    void loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state);
     193    void loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName);
     194
     195    void setFeaturePosition(FeaturePosition featurePosition);
     196    void setFeaturePositionS(const std::string& featurePosition);
     197
     198    void setFont(Font* font);
     199    void setFont(const std::string& fontName);
     200
     201    void setAnimatedStateChanges(bool animated);
     202    void switchState(OrxGui::State state);
     203
     204
    99205
    100206    inline void drawRect(const Rect2D& rect) const
     
    116222    virtual bool processEvent(const Event& event) { return false; };
    117223
     224    bool getState(const std::string& stateName, OrxGui::State* state);
    118225
    119226  protected:
     
    137244    virtual void destroyed();
    138245
     246    virtual void debug() const;
     247
    139248  private:
    140249    void init();
    141250
    142251  private:
     252    static GLGuiWidget*            _selected;         //!< The currently selected Widget.
     253    static GLGuiWidget*            _focused;          //!< The currently Focused Widget.
     254    static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input.
     255
     256
     257    /// WIDGET
    143258    GLGuiWidget*                   _parent;           //!< The parent of this Widget.
    144259
    145260    /// LOOKS
    146     Material                       _backMat;
    147261    Rect2D                         _backRect;
    148 
    149     Color                          _frontColor;
    150     Color*                         _toFrontColor;
    151 
    152     float                          _borderLeft;
    153     float                          _borderRight;
    154     float                          _borderTop;
    155     float                          _borderBottom;
    156 
    157262    Vector2D                       _minSize;
    158263
    159     GLGuiStyle                     _style;
    160264
    161265    /// EVENTS
     266    OrxGui::State                  _state;
     267
    162268    bool                           _focusable;        //!< If this widget can receive focus.
    163269    bool                           _clickable;        //!< if this widget can be clicked upon.
     
    166272
    167273
    168     static GLGuiWidget*            _selected;         //!< The currently selected Widget.
    169     static GLGuiWidget*            _focused;          //!< The currently Focused Widget.
    170 
    171     static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input.
     274
     275    /// STYLE - Variables.
     276    typedef struct
     277    {
     278      float             _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
     279      float             _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
     280      float             _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
     281      float             _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
     282
     283      float             _textSize;             //!< The TextSize of the Widget.
     284
     285      Material          _background;           //!< The Background Material of the Widget.
     286
     287      Material          _foreground;           //!< The foreground Material of the Widget.
     288    }
     289    StatedStyle;
     290
     291
     292    StatedStyle         _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States
     293
     294    FeaturePosition     _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
     295    Font*               _font;                 //!< The Font used in the current Widget.
     296
     297
     298    /// ANIMATION STUFF:
     299    bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
     300
     301    bool                _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
     302    float               _animationCycle;
     303    float               _animationDuration;
     304    StatedStyle         _currentStyle;
     305
    172306  };
    173307}
  • trunk/src/lib/gui/gl/specials/glgui_notifier.cc

    r8518 r8619  
    2525
    2626  /**
    27    * standard constructor
     27   * @brief standard constructor
    2828   */
    2929  GLGuiNotifier::GLGuiNotifier ()
     
    3434    this->lineSpacing = 0;
    3535    this->linesProcessed = 0;
     36    this->_fadeAge = 3.0;
     37    this->setHideAge(4.0);
    3638
    3739    this->setDisplayLineCount(10);
     
    5759  }
    5860
     61  /**
     62   * @brief push a message onto the notifier.
     63   * @param message the message to be pushed.
     64   *
     65   * @note it is not guaranteed, that the message is delivered instantaniously
     66   * The possibility may arise, that the DisplayLines are all in use, then one
     67   * has to wait until a line gets hidden, until a new one can be pushed to be
     68   * displayed.
     69   */
    5970  void GLGuiNotifier::pushNotifyMessage(const std::string& message)
    6071  {
    6172    if (!this->hiddenText.empty())
    6273    {
    63       printf("%s\n", message.c_str());
    64       DisplayLine dl;
     74      DisplayLine dl; // put everything in here, and then display it
     75
     76      // retrieve a Text.
    6577      dl.text = this->hiddenText.top();
    66 
     78      this->hiddenText.pop();
     79
     80      // setup Text
    6781      dl.text->setBlending(1.0f);
    6882      dl.text->setText(message);
    69       this->hiddenText.pop();
     83      dl.text->setVisibility(true);
     84      dl.text->setRelCoor2D(this->calculateLinePosition(0));
     85
    7086      dl.age = 0.0f;
    7187      this->displayLines.push_front(dl);
    72 
    73       dl.text->setVisibility(true);
    74       dl.text->setRelCoor2D(this->calculateLinePosition(0));
    7588      this->repositionText();
    7689    }
    7790    else
    7891    {
     92      // push it onto the List of messages we still need.
    7993      this->inputBuffer.push_front(message);
    80       //printf("grumble... must be fixed\n");
    81     }
    82   }
    83 
    84 
     94    }
     95  }
     96
     97
     98  /**
     99   * @brief sets the Dipsplay Line Count of the Notifier.
     100   * @param coun the count of displayLines.
     101   */
    85102  void GLGuiNotifier::setDisplayLineCount(unsigned int count)
    86103  {
     
    96113  }
    97114
     115  void GLGuiNotifier::setFadeAge(float fadeAge)
     116  {
     117    this->_fadeAge = fadeAge;
     118    this->_transformAge = hideAge() - this->fadeAge();
     119  }
     120
     121  void GLGuiNotifier::setHideAge(float hideAge)
     122  {
     123    this->_hideAge = hideAge;
     124    this->_transformAge = this->hideAge() - fadeAge();
     125  }
     126
    98127
    99128  /**
     
    119148  void GLGuiNotifier::applyTextSettings(MultiLineText* text)
    120149  {
    121     text->setSize(this->style().textSize());
     150    text->setSize(this->textSize());
    122151    text->setLineWidth( 300 );
    123     text->setFont("fonts/final_frontier.ttf", (int)this->style().textSize());
    124 
    125     text->setColor(this->style().foregroundColor() );
     152    text->setFont("fonts/final_frontier.ttf", (int)this->textSize());
     153
     154    text->setColor(this->foregroundColor() );
    126155    if (text->getParent2D() != this)
    127156      text->setParent2D(this);
     
    129158
    130159
     160  /**
     161   * @brief ticks the entire Notifier.
     162   * @param dt the time passed since the last Tick
     163   */
    131164  void GLGuiNotifier::tick(float dt)
    132165  {
     
    135168    {
    136169      (*line).age+=dt;
    137       if ((*line).age > 3.0f)
     170      if ((*line).age > this->fadeAge())
    138171      {
    139         (*line).text->setBlending(4.0 - (*line).age);
    140         if ((*line).age > 4.0f)
     172        (*line).text->setBlending((hideAge() - (*line).age)/_transformAge);
     173        if ((*line).age > hideAge())
    141174        {
    142175          std::list<DisplayLine>::iterator tmp = line;
     
    167200    this->beginDraw();
    168201
    169     this->backMaterial().select();
     202    this->background().select();
    170203    this->drawRect(this->backRect());
    171204    this->endDraw();
     
    183216  Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber)
    184217  {
    185     return Vector2D(0.0f, (float)(this->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
     218    return Vector2D(0.0f, (float)(textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
    186219  }
    187220
  • trunk/src/lib/gui/gl/specials/glgui_notifier.h

    r8518 r8619  
    3030    void pushNotifyMessage(const std::string& message);
    3131
    32     // BUFFERS
     32    /// Setup
    3333    void setDisplayLineCount(unsigned int count);
     34    void setFadeAge(float fadeAge);
     35    void setHideAge(float hideAge);
     36
     37    /** @returns the beginning of the Hiding process */
     38    inline float fadeAge() const { return _fadeAge; };
     39    /** @returns at what age elements should be fully hidden */
     40    inline float hideAge() const { return _hideAge; };
    3441
    3542    void clear();
     
    5461
    5562  private:
     63    //! structure that defines a Displayed line.
    5664    typedef struct
    5765    {
     
    5967      MultiLineText*    text;
    6068
    61     }
    62     DisplayLine;
     69    } DisplayLine;
     70
     71
     72    float                       _fadeAge;
     73    float                       _hideAge;
     74    float                       _transformAge;
    6375
    6476    unsigned int                lineSpacing;            //!< The Spacing between lines.
     
    7284
    7385    unsigned long               linesProcessed;         //!< How many Lines have been processed so far.
    74     std::list<std::string>      inputBuffer;            //!<
     86    std::list<std::string>      inputBuffer;            //!< The input buffer for lines that were not yet printet out, because there is too much input.
    7587
    7688  };
  • trunk/src/lib/math/rect2D.cc

    r8448 r8619  
    475475}
    476476
     477/**
     478 * @brief print debug output for the Rect
     479 */
     480void Rect2D::debug() const
     481{
     482  PRINT(0)("Top: %0.2f Left: %0.2f; Bottom %0.2f Right:%0.2f; Size: %0.2fx%0.2f\n", top(), left(), bottom(), right(), size().x, size().y);
     483}
  • trunk/src/lib/math/rect2D.h

    r8448 r8619  
    127127  const Rect2D& slerp(const Rect2D& rect, float value);
    128128
     129  void debug() const;
     130
    129131private:
    130132  Vector2D _topLeft;
  • trunk/src/lib/sound/sound_buffer.cc

    r8362 r8619  
    114114    else if (stereo && !is16Bit)
    115115      return AL_FORMAT_STEREO8;
    116     else if (stereo && is16Bit)
     116    else /* if (stereo && is16Bit) */
    117117      return AL_FORMAT_STEREO16;
    118118  }
  • trunk/src/lib/util/color.cc

    r8448 r8619  
    2424  printf("r:%0.2f g:%0.2f, b:%0.2f, a:%0.2f\n", r(), g(), b(), a());
    2525}
     26
     27
    2628
    2729/**
  • trunk/src/lib/util/executor/functor_list.h

    r8048 r8619  
    144144  FUNCTOR_LIST(3)(l_STRING, l_UINT, l_UINT);
    145145
     146  FUNCTOR_LIST(5)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_STRING);
     147
    146148#endif /* FUNCTOR_LIST */
  • trunk/src/lib/util/filesys/file.cc

    r8333 r8619  
    205205
    206206/// FIXME NEXT THREE FUNCTIONS
    207 bool File::isReadeable() const
     207bool File::isReadable() const
    208208{
    209209#ifndef __WIN32__
  • trunk/src/lib/util/filesys/file.h

    r8333 r8619  
    5151  bool isFile() const;
    5252  bool isDirectory() const;
    53   bool isReadeable() const;
     53  bool isReadable() const;
    5454  bool isWriteable() const;
    5555  bool isExecutable() const;
  • trunk/src/story_entities/simple_game_menu.cc

    r8523 r8619  
    120120    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
    121121    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
    122     slider->connect(SIGNAL(slider, valueChanged), box, SLOT(OrxGui::GLGuiWidget, setBackgroundColor));
    123122    slider->setRange(0, 1);
    124123    slider->setValue(slider->min());
    125124    box->pack(slider);
     125
     126
     127    OrxGui::GLGuiTable* table = new OrxGui::GLGuiTable(3, 3);
     128    std::vector<std::string> headers;
     129    headers.push_back("1");
     130    headers.push_back("2");
     131    headers.push_back("3");
     132    table->setHeader(headers);
     133
     134
     135    box->pack(table);
    126136  }
    127137  box->setAbsCoor2D(50, 200);
  • trunk/src/util/hud.cc

    r8518 r8619  
    8989  {
    9090    this->energyWidget->show();
    91     this->energyWidget->backMaterial().setDiffuseMap("hud_energy_background.png");
    92     this->energyWidget->backMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     91    this->energyWidget->setBackgroundTexture( "hud_energy_background.png");
    9392    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    9493        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    143142      {
    144143        weapon->getEnergyWidget()->show();
    145         weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
    146         weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
     144        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
    147145        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    148146        //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
  • trunk/src/world_entities/environments/mapped_water.cc

    r8312 r8619  
    8080  memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
    8181  //mat.select();
    82   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
     82  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(0));
    8383  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    8484  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
     
    9090  unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];
    9191  memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
    92   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
     92  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1));
    9393  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    9494  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
     
    281281  ///
    282282
    283   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
     283  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(0));
    284284
    285285  // Create the texture and store it on the video card
     
    351351  if(pos.y > waterHeight)
    352352  {
    353     double plane[4] = {0.0, -1.0, 0.0, waterHeight}; 
     353    double plane[4] = {0.0, -1.0, 0.0, waterHeight};
    354354    glClipPlane(GL_CLIP_PLANE0, plane);
    355355
     
    359359  {
    360360    glCullFace(GL_FRONT);
    361     double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; 
     361    double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
    362362    glClipPlane(GL_CLIP_PLANE0, plane);
    363363  }
     
    370370
    371371
    372   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
     372  glBindTexture(GL_TEXTURE_2D, this->mat.diffuseTextureID(1));
    373373
    374374  // Create the texture and store it on the video card
  • trunk/src/world_entities/skybox.h

    r7954 r8619  
    5353                           const std::string& posY, const std::string& negZ, const std::string& posZ);
    5454
    55   GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->getDiffuseTexture(): 0; };
     55  GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->diffuseTextureID(): 0; };
    5656
    5757  static void enableCubeMap();
     
    6969  float           textureSize;     //!< this is the length of a texture (assumes a square texture)
    7070  std::string     textureName;     //!< Name of the Texture
    71  
     71
    7272  int textureName_handle;          //!< used to notify about changes of textureName
    7373  int size_handle;                 //!< used to notify about changes of size
Note: See TracChangeset for help on using the changeset viewer.