commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
53
include/framework/color/color.cpp
Normal file
53
include/framework/color/color.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "color/color.h"
|
||||
|
||||
using namespace GS;
|
||||
|
||||
Color Color::White(1, 1, 1),
|
||||
Color::Grey(0.5, 0.5, 0.5),
|
||||
Color::Black(0, 0, 0),
|
||||
Color::Red(1, 0, 0),
|
||||
Color::Green(0, 1, 0),
|
||||
Color::Blue(0, 0, 1),
|
||||
Color::Yellow(1, 1, 0),
|
||||
Color::Purple(1, 0, 1);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
uint Color::AsInteger() const
|
||||
{
|
||||
uint value;
|
||||
uchar *pl = (uchar *)&(value);
|
||||
#if (__PLATFORM_WINDOWS__ || __PLATFORM_LINUX__ || __PLATFORM_NINTENDO_WII__)
|
||||
float tmp_x = (x * 255.f) + 256.f,
|
||||
tmp_y = (y * 255.f) + 256.f,
|
||||
tmp_z = (z * 255.f) + 256.f,
|
||||
tmp_w = (w * 255.f) + 256.f;
|
||||
|
||||
pl[0] = (uchar)((((int &)tmp_x) & 0x7fffff) >> 15);
|
||||
pl[1] = (uchar)((((int &)tmp_y) & 0x7fffff) >> 15);
|
||||
pl[2] = (uchar)((((int &)tmp_z) & 0x7fffff) >> 15);
|
||||
pl[3] = (uchar)((((int &)tmp_w) & 0x7fffff) >> 15);
|
||||
#else
|
||||
pl[0] = (uchar)(Types::Clamp(x, 0.f, 1.f) * 255.f);
|
||||
pl[1] = (uchar)(Types::Clamp(y, 0.f, 1.f) * 255.f);
|
||||
pl[2] = (uchar)(Types::Clamp(z, 0.f, 1.f) * 255.f);
|
||||
pl[3] = (uchar)(Types::Clamp(w, 0.f, 1.f) * 255.f);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
void Color::FromInteger(uint value)
|
||||
{
|
||||
const uchar *pl = (const uchar *)&(value);
|
||||
const float i255 = 1.f / 255.f;
|
||||
x = (float)(pl[0]) * i255;
|
||||
y = (float)(pl[1]) * i255;
|
||||
z = (float)(pl[2]) * i255;
|
||||
w = (float)(pl[3]) * i255;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user