Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8376 in orxonox.OLD for trunk/src/lib/util


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/lib/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.