Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8376 in orxonox.OLD


Ignore:
Timestamp:
Jun 14, 2006, 12:13:16 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: no more seg-fault when copying a Texture

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/material.cc

    r8370 r8376  
    132132
    133133    // setting diffuse color
    134   glColor4f (diffuse[0], diffuse[1], diffuse[2], this->transparency);
     134  glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a());
    135135  // setting ambient color
    136   glMaterialfv(GL_FRONT, GL_AMBIENT, this->ambient);
     136  glMaterialfv(GL_FRONT, GL_AMBIENT, &this->ambient[0]);
    137137  // setting up Sprecular
    138   glMaterialfv(GL_FRONT, GL_SPECULAR, this->specular);
     138  glMaterialfv(GL_FRONT, GL_SPECULAR, &this->specular[0]);
    139139  // setting up Shininess
    140140  glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
    141141
    142142  // setting the transparency
    143   if (this->transparency < 1.0 ||       /* This allows alpha blending of 2D textures with the scene */
     143  if (this->diffuse.a() < 1.0 ||       /* This allows alpha blending of 2D textures with the scene */
    144144      (likely(!this->textures.empty() && this->textures[0].hasAlpha())))
    145145  {
     
    206206{
    207207  PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    208   this->diffuse[0] = r;
    209   this->diffuse[1] = g;
    210   this->diffuse[2] = b;
    211   this->diffuse[3] = 1.0;
    212 
     208  this->diffuse = Color(r, g, b, this->diffuse.a() );
    213209}
    214210
     
    223219{
    224220  PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    225   this->ambient[0] = r;
    226   this->ambient[1] = g;
    227   this->ambient[2] = b;
    228   this->ambient[3] = 1.0;
     221  this->ambient = Color(r, g, b, 1.0);
    229222}
    230223
     
    238231{
    239232  PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    240   this->specular[0] = r;
    241   this->specular[1] = g;
    242   this->specular[2] = b;
    243   this->specular[3] = 1.0;
     233  this->specular = Color (r, g, b, 1.0);
    244234}
    245235
     
    260250{
    261251  PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getName(), trans);
    262   this->transparency = trans;
     252  this->diffuse.a() = trans;
    263253}
    264254
     
    310300    Texture* tex = dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target));
    311301    if (tex != NULL)
    312     this->textures[textureNumber] = *tex;
     302      this->textures[textureNumber] = *tex;
    313303    else
    314304      this->textures[textureNumber] = Texture();
     
    373363 * @brief Sets the Materials Ambient Map
    374364 * @todo implement this
    375 */
     365 */
    376366void Material::setAmbientMap(const std::string& aMap, GLenum target)
    377367{
     
    383373 * @brief Sets the Materials Specular Map
    384374 * @param sMap the Name of the Image to Use
    385    @todo implement this
    386 */
     375 * @todo implement this
     376 */
    387377void Material::setSpecularMap(const std::string& sMap, GLenum target)
    388378{
     
    395385 * @param bump the Name of the Image to Use
    396386 * @todo implemet this
    397 */
     387 */
    398388void Material::setBump(const std::string& bump)
    399389{
  • trunk/src/lib/graphics/importer/material.h

    r8370 r8376  
    1717#include <vector>
    1818#include "texture.h"
     19#include "color.h"
    1920
    2021// FORWARD DECLARATIONS //
     
    3536    void setIllum (int illum);
    3637    int getIllumModel() const { return this->illumModel; };
     38
    3739    void setDiffuse (float r, float g, float b);
    3840    void setAmbient (float r, float g, float b);
     
    4244    void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
    4345
    44     void getDiffuseColor(float& r, float& g, float& b) const { r = diffuse[0], g = diffuse[1], b = diffuse[2]; }
     46    const Color& getDiffuseColor() const { return diffuse; };
    4547
    4648    // MAPPING //
     
    6668
    6769    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
    68     float            diffuse [4];      //!< The diffuse color of the Material.
    69     float            ambient [4];      //!< The ambient color of the Material.
    70     float            specular [4];     //!< The specular color of the Material.
     70    Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
     71    Color            ambient;          //!< The ambient color of the Material.
     72    Color            specular;         //!< The specular color of the Material.
    7173    float            shininess;        //!< The shininess of the Material.
    72     float            transparency;     //!< The transperency of the Material.
    7374    GLenum           sFactor;          //!< The Blending Factor for the Source.
    7475    GLenum           tFactor;          //!< The Blending Factor for the Destination.
  • trunk/src/lib/graphics/importer/texture.cc

    r8366 r8376  
    163163Texture::~Texture()
    164164{}
     165
     166/**
     167 * @brief copies the Data from texture to this texture.
     168 * @param texture the Texture to copy into this one.
     169 * @returns the Texture.
     170 */
     171Texture& Texture::operator=(const Texture& texture)
     172{
     173  this->data = texture.data;
     174
     175  return *this;
     176}
    165177
    166178
  • trunk/src/lib/graphics/importer/texture.h

    r8363 r8376  
    2626  Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    2727  Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
     28
     29  Texture& operator=(const Texture& texture);
    2830
    2931  virtual ~Texture();
  • trunk/src/lib/util/color.cc

    r7919 r8376  
    1818#include "color.h"
    1919#include <stdio.h>
    20 
    21 using namespace std;
    22 
    2320
    2421/**
  • trunk/src/lib/util/color.h

    r8145 r8376  
    1616{
    1717public:
    18   Color(float r, float g, float b, float a) :_r(r), _g(g), _b(b), _a(a) {};
    19   Color(const Color& c) { _r = c._r; _g = c._g; _b = c._b; _a = c._a; };
     18  Color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 0.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     19  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2020
    21   float r() const { return _r; }
    22   float& r() { return _r; }
    23   float g() const { return _g; }
    24   float& g() { return _g; }
    25   float b() const { return _b; }
    26   float& b() { return _b; }
    27   float a() const { return _a; }
    28   float& a() { return _a; }
     21  float& operator[](unsigned int i) { return _rgba[i]; }
     22  const float& operator[](unsigned int i) const { return _rgba[i]; }
    2923
     24  float r() const { return _rgba[0]; }
     25  float& r() { return _rgba[0]; }
     26  float g() const { return _rgba[1]; }
     27  float& g() { return _rgba[1]; }
     28  float b() const { return _rgba[2]; }
     29  float& b() { return _rgba[2]; }
     30  float a() const { return _rgba[3]; }
     31  float& a() { return _rgba[3]; }
     32
     33
     34  /// STATIC TRANSFORMATIONS
    3035public:
    3136  static Vector RGBtoHSV (const Vector& RGB);
     
    3843  static float maxrgb(float r, float g, float b);
    3944
    40   float       _r;     //!< Red Value.
     45private:
     46  float       _rgba[4]; //!< Color Values
     47
     48  /*  float       _r;     //!< Red Value.
    4149  float       _g;     //!< Green Value.
    4250  float       _b;     //!< Blue Value.
    43   float       _a;     //!< Alpha Value.
    44 
     51  float       _a;     //!< Alpha Value.*/
    4552};
    4653
  • trunk/src/story_entities/simple_game_menu.cc

    r8330 r8376  
    7575  OrxGui::GLGuiHandler::getInstance()->activateCursor();
    7676  OrxGui::GLGuiHandler::getInstance()->activate();
    77   OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 0, 49);
     77  OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 1, 49);
    7878  /////
    7979
Note: See TracChangeset for help on using the changeset viewer.