Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7919 in orxonox.OLD for trunk/src/lib/graphics


Ignore:
Timestamp:
May 28, 2006, 3:48:13 PM (19 years ago)
Author:
bensch
Message:

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

Location:
trunk/src/lib/graphics
Files:
8 edited

Legend:

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

    r7871 r7919  
    286286  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);   //Use at least 16 bits for the depth buffer
    287287  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);  //Enable double buffering
     288
     289  glEnable(GL_CULL_FACE);
     290  glCullFace(GL_FRONT);
    288291}
    289292
     
    576579void GraphicsEngine::drawBackgroundElements() const
    577580{
     581  GraphicsEngine::storeMatrices();
     582
    578583  Render2D::getInstance()->draw(E2D_LAYER_BELOW_ALL, E2D_LAYER_BELOW_ALL);
    579584}
  • trunk/src/lib/graphics/importer/material.cc

    r7848 r7919  
    108108      return true;
    109109
    110 
    111   // setting diffuse color
     110  if (likely(Material::selectedMaterial != NULL))
     111  {
     112    for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     113    {
     114        glActiveTexture(Material::glTextureArbs[i]);
     115        //glBindTexture(GL_TEXTURE_2D, 0);
     116        glDisable(GL_TEXTURE_2D);
     117    }
     118  }
     119
     120    // setting diffuse color
    112121  glColor4f (diffuse[0], diffuse[1], diffuse[2], this->transparency);
    113122  // setting ambient color
     
    118127  glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
    119128
    120 
    121129  // setting the transparency
    122130  if (this->transparency < 1.0 ||       /* This allows alpha blending of 2D textures with the scene */
     
    138146    glShadeModel(GL_SMOOTH);
    139147
    140   if (likely(Material::selectedMaterial != NULL))
    141   {
    142     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
    143     {
    144         glActiveTexture(Material::glTextureArbs[i]);
    145         glBindTexture(GL_TEXTURE_2D, 0);
    146         glDisable(GL_TEXTURE_2D);
    147     }
    148   }
    149148
    150149  for(unsigned int i = 0; i < this->textures.size(); ++i)
     
    159158  }
    160159  Material::selectedMaterial = this;
    161 
    162   /*  if (this->diffuseTexture != NULL)
    163       {
    164         glEnable(GL_TEXTURE_2D);
    165         glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
    166       }
    167     else
    168       {
    169         glDisable(GL_TEXTURE_2D);
    170         glBindTexture(GL_TEXTURE_2D, 0);
    171       }*/
    172160}
    173161
  • trunk/src/lib/graphics/importer/material.h

    r7788 r7919  
    1616
    1717#include <vector>
    18 #include "SDL_image.h"
    19 
    2018#include "texture.h"
    2119
     
    5149    void setTransparency (char* trans);
    5250
     51    void getDiffuseColor(float& r, float& g, float& b) const { r = diffuse[0], g = diffuse[1], b = diffuse[2]; }
    5352
    5453    // MAPPING //
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7871 r7919  
    6262  this->toCoordinate = NULL;
    6363  this->toDirection = NULL;
     64
     65  this->size = Vector2D(0,0);
    6466  this->toSize = NULL;
    65   this->setSize2D(1, 1);
    6667
    6768
     
    448449  this->relCoordinate += shift;
    449450  this->bRelCoorChanged = true;
    450 
    451451}
    452452
     
    847847    if (unlikely(this->toSize != NULL))
    848848    {
    849       Vector2D shiftSize = (*this->toSize - Vector2D(this->sizeX, this->sizeY)) *fabsf(dt)*bias;
     849      Vector2D shiftSize = (*this->toSize - this->size) *fabsf(dt)*bias;
    850850      if (likely((shiftSize).len() >= .001))//PNODE_ITERATION_DELTA))
    851851      {
    852         this->sizeX += shiftSize.x;
    853         this->sizeY += shiftSize.y;
     852        this->size += shiftSize;
    854853      }
    855854      else
     
    11091108  if (level == 0)
    11101109    glPopAttrib();
    1111 
    11121110}
    11131111
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7843 r7919  
    125125    inline const PNode* getBindNode() const { return this->bindNode; };
    126126
    127     inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; };
     127    inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
     128    inline void setSize2D(const Vector2D& size) { this->size = size; };
     129    inline const Vector2D& getSize2D() const { return this->size; };
    128130    void setSizeSoft2D(float x, float y, float bias = 1.0);
    129     inline void setSizeX2D(float x) { this->sizeX = x; };
    130     inline void setSizeY2D(float y) { this->sizeY = y; };
    131     inline float getSizeX2D() const { return this->sizeX; };
    132     inline float getSizeY2D() const { return this->sizeY; };
     131    inline void setSizeX2D(float x) { this->size.x = x; };
     132    inline void setSizeY2D(float y) { this->size.y = y; };
     133    inline float getSizeX2D() const { return this->size.x; };
     134    inline float getSizeY2D() const { return this->size.y; };
    133135
    134136  public:
     
    238240  private:
    239241    const PNode*            bindNode;           //!< a node over which to display this 2D-element
    240     float                   sizeX;              //!< The size of the rendered item in x-direction
    241     float                   sizeY;              //!< The size of the rendered Item in y-direction
     242    Vector2D                size;               //!< The size of the rendered item
    242243    Vector2D*               toSize;             //!< The Size to iterate to.
    243244
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r7758 r7919  
    6464    return;
    6565  glPushMatrix();
     66  glPushAttrib(GL_ENABLE_BIT);
    6667  // transform for alignment.
    6768  // TODO make the Stuff with the alignment
     
    117118  }
    118119  glEnd();
     120  glPopAttrib();
    119121  glPopMatrix();
    120122}
  • trunk/src/lib/graphics/text_engine/text.cc

    r7753 r7919  
    3636  this->font = NULL;
    3737  this->size = textSize;
     38  this->setSizeY2D(size);
    3839  this->blending = TEXT_DEFAULT_BLENDING;
    3940  this->color = TEXT_DEFAULT_COLOR;
     
    127128
    128129/**
     130 * @brief appends one Character to the String.
     131 */
     132void Text::appendCharacter(char character)
     133{
     134  this->text += character;
     135  this->setupTextWidth();
     136}
     137
     138
     139/**
    129140 * @brief append some text to the already existing Text.
    130141 * @param appendText The text to append to this Text.
     
    135146  return this->text;
    136147}
     148
     149/**
     150 * @brief removes char characters from the Text.
     151 *
     152 * @note this function checks, if the count can be removed, and if so does it.
     153 * Otherwise the maximum count of characters will be removed.
     154 */
     155void Text::removeCharacters(unsigned int chars)
     156{
     157  if (text.size() > chars)
     158    this->text.resize(this->text.size()-chars);
     159  else if (!text.empty())
     160    text.clear();
     161  this->setupTextWidth();
     162}
     163
    137164
    138165/**
     
    188215    return;
    189216  glPushMatrix();
     217  glPushAttrib(GL_ENABLE_BIT);
    190218  // transform for alignment.
    191219  if (this->getAlignment() == TEXT_ALIGN_RIGHT)
     
    229257  }
    230258  glEnd();
     259  glPopAttrib();
    231260  glPopMatrix();
    232261}
     
    242271    if(this->font->getGlyphArray()[this->text[i]] != NULL)
    243272      width += this->font->getGlyphArray()[this->text[i]]->advance;
    244   this->setSizeX2D(width *this->getSize());
     273  this->setSizeX2D(width * this->getSize());
    245274}
    246275
  • trunk/src/lib/graphics/text_engine/text.h

    r7753 r7919  
    3737    void setText(const std::string& text);
    3838    void append(const std::string& appendText);
     39    void appendCharacter(char character);
    3940    const std::string& operator<<(const std::string& appendText);
     41    void removeCharacters(unsigned int chars);
    4042
    4143    /// SETUP
Note: See TracChangeset for help on using the changeset viewer.