I guess you've herad this before, but please bear with me.
I'm doing some opengl programming and've made this class:
Code:
struct Color
{
Color() {}
Color(float r_, float g_, float b_) : r(r_), g(g_), b(b_) {}
void Set(float r_, float g_, float b_);
void Invert();
static Color Invert(Color& color);
void AdjustBrightness(float adjustment); // in percent e.g. (1.3 - 0.3)
float r, g, b, a;
static Color GetPredefined(int color);
void SetToPredefined(int color);
enum
{
Red,
Green,
Blue,
Yellow,
Oranage,
Brown,
White,
Black
};
static Color PredefinedColors[];
void operator=(int predefined_color);
bool operator==(Color& c);
};
Can I safely do this?
Code:
Color a;
glColor4fv(&a.r); //expects an 4 sized GLfloat array with r,g,b,a
If I can, can I do this on more complex classes too?
Thanks!