Making CColor use floats instead of u8s
This commit is contained in:
parent
f11a8b938b
commit
6b8966f0b9
|
@ -1,114 +1,120 @@
|
|||
#include "CColor.h"
|
||||
|
||||
CColor::CColor()
|
||||
: r(0.f), g(0.f), b(0.f), a(0.f)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
}
|
||||
|
||||
CColor::CColor(CInputStream& src)
|
||||
CColor::CColor(CInputStream& rInput, bool Integral /*= false*/)
|
||||
{
|
||||
src.ReadBytes(&r, 4);
|
||||
}
|
||||
|
||||
CColor::CColor(u32 rgba)
|
||||
{
|
||||
r = (rgba >> 24) & 0xFF;
|
||||
g = (rgba >> 16) & 0xFF;
|
||||
b = (rgba >> 8) & 0xFF;
|
||||
a = rgba & 0xFF;
|
||||
}
|
||||
|
||||
CColor::CColor(u8 rgba)
|
||||
{
|
||||
r = g = b = a = rgba;
|
||||
}
|
||||
|
||||
CColor::CColor(u8 _r, u8 _g, u8 _b, u8 _a)
|
||||
{
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
if (Integral)
|
||||
{
|
||||
r = (u8) rInput.ReadByte() / 255.f;
|
||||
g = (u8) rInput.ReadByte() / 255.f;
|
||||
b = (u8) rInput.ReadByte() / 255.f;
|
||||
a = (u8) rInput.ReadByte() / 255.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = rInput.ReadFloat();
|
||||
g = rInput.ReadFloat();
|
||||
b = rInput.ReadFloat();
|
||||
a = rInput.ReadFloat();
|
||||
}
|
||||
}
|
||||
|
||||
CColor::CColor(float rgba)
|
||||
: r(rgba), g(rgba), b(rgba), a(rgba)
|
||||
{
|
||||
r = g = b = a = u8(rgba * 255.f);
|
||||
}
|
||||
|
||||
CColor::CColor(float _r, float _g, float _b, float _a)
|
||||
CColor::CColor(float _r, float _g, float _b, float _a /*= 1.f*/)
|
||||
: r(_r), g(_g), b(_b), a(_a)
|
||||
{
|
||||
r = u8(_r * 255.f);
|
||||
g = u8(_g * 255.f);
|
||||
b = u8(_b * 255.f);
|
||||
a = u8(_a * 255.f);
|
||||
}
|
||||
|
||||
void CColor::Write(COutputStream &Output)
|
||||
void CColor::SetIntegral(u8 rgba)
|
||||
{
|
||||
Output.WriteBytes(&r, 4);
|
||||
float f = rgba / 255.f;
|
||||
r = g = b = a = f;
|
||||
}
|
||||
|
||||
long CColor::AsLongRGBA() const
|
||||
void CColor::SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a /*= 255*/)
|
||||
{
|
||||
return (r << 24) | (g << 16) | (b << 8) | a;
|
||||
r = _r / 255.f;
|
||||
g = _g / 255.f;
|
||||
b = _b / 255.f;
|
||||
a = _a / 255.f;
|
||||
}
|
||||
|
||||
void CColor::Write(COutputStream &rOutput, bool Integral /*= false*/)
|
||||
{
|
||||
if (Integral)
|
||||
{
|
||||
rOutput.WriteLong(ToLongRGBA());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rOutput.WriteFloat(r);
|
||||
rOutput.WriteFloat(g);
|
||||
rOutput.WriteFloat(b);
|
||||
rOutput.WriteFloat(a);
|
||||
}
|
||||
}
|
||||
|
||||
long CColor::ToLongRGBA() const
|
||||
{
|
||||
u8 _r = (u8) (r * 255);
|
||||
u8 _g = (u8) (g * 255);
|
||||
u8 _b = (u8) (b * 255);
|
||||
u8 _a = (u8) (a * 255);
|
||||
return (_r << 24) | (_g << 16) | (_b << 8) | _a;
|
||||
}
|
||||
|
||||
long CColor::ToLongARGB() const
|
||||
{
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
u8 _r = (u8) (r * 255);
|
||||
u8 _g = (u8) (g * 255);
|
||||
u8 _b = (u8) (b * 255);
|
||||
u8 _a = (u8) (a * 255);
|
||||
return (_a << 24) | (_r << 16) | (_g << 8) | _b;
|
||||
}
|
||||
|
||||
CVector4f CColor::ToVector4f() const
|
||||
bool CColor::operator==(const CColor& rkOther) const
|
||||
{
|
||||
return CVector4f(float(r) / 255.f,
|
||||
float(g) / 255.f,
|
||||
float(b) / 255.f,
|
||||
float(a) / 255.f);
|
||||
return ((r == rkOther.r) &&
|
||||
(g == rkOther.g) &&
|
||||
(b == rkOther.b) &&
|
||||
(a == rkOther.a));
|
||||
}
|
||||
|
||||
bool CColor::operator==(const CColor& other) const
|
||||
bool CColor::operator!=(const CColor& rkOther) const
|
||||
{
|
||||
return ((r == other.r) &&
|
||||
(g == other.g) &&
|
||||
(b == other.b) &&
|
||||
(a == other.a));
|
||||
return (!(*this == rkOther));
|
||||
}
|
||||
|
||||
bool CColor::operator!=(const CColor& other) const
|
||||
CColor CColor::operator+(const CColor& rkOther) const
|
||||
{
|
||||
return (!(*this == other));
|
||||
float NewR = fmin(r + rkOther.r, 1.f);
|
||||
float NewG = fmin(g + rkOther.g, 1.f);
|
||||
float NewB = fmin(b + rkOther.b, 1.f);
|
||||
float NewA = fmin(a + rkOther.a, 1.f);
|
||||
return CColor(NewR, NewG, NewB, NewA);
|
||||
}
|
||||
|
||||
CColor CColor::operator+(const CColor& other) const
|
||||
void CColor::operator+=(const CColor& rkOther)
|
||||
{
|
||||
u16 NewR = r + other.r;
|
||||
if (NewR > 255) NewR = 255;
|
||||
u16 NewG = g + other.g;
|
||||
if (NewG > 255) NewG = 255;
|
||||
u16 NewB = b + other.b;
|
||||
if (NewB > 255) NewB = 255;
|
||||
u16 NewA = a + other.a;
|
||||
if (NewA > 255) NewA = 255;
|
||||
return CColor((u8) NewR, (u8) NewG, (u8) NewB, (u8) NewA);
|
||||
*this = (*this + rkOther);
|
||||
}
|
||||
|
||||
void CColor::operator+=(const CColor& other)
|
||||
CColor CColor::operator-(const CColor& rkOther) const
|
||||
{
|
||||
*this = (*this + other);
|
||||
}
|
||||
|
||||
CColor CColor::operator-(const CColor& other) const
|
||||
{
|
||||
s16 NewR = r - other.r;
|
||||
if (NewR < 0) NewR = 0;
|
||||
s16 NewG = g - other.g;
|
||||
if (NewG < 0) NewG = 0;
|
||||
s16 NewB = b - other.b;
|
||||
if (NewB < 0) NewB = 0;
|
||||
s16 NewA = a - other.a;
|
||||
if (NewA < 0) NewA = 0;
|
||||
return CColor((u8) NewR, (u8) NewG, (u8) NewB, (u8) NewA);
|
||||
float NewR = fmax(r - rkOther.r, 0.f);
|
||||
float NewG = fmax(g - rkOther.g, 0.f);
|
||||
float NewB = fmax(b - rkOther.b, 0.f);
|
||||
float NewA = fmax(a - rkOther.a, 0.f);
|
||||
return CColor(NewR, NewG, NewB, NewA);
|
||||
}
|
||||
|
||||
void CColor::operator-=(const CColor& other)
|
||||
|
@ -116,96 +122,106 @@ void CColor::operator-=(const CColor& other)
|
|||
*this = (*this - other);
|
||||
}
|
||||
|
||||
CColor CColor::operator*(const CColor& other) const
|
||||
CColor CColor::operator*(const CColor& rkOther) const
|
||||
{
|
||||
CVector4f A = ToVector4f();
|
||||
CVector4f B = other.ToVector4f();
|
||||
|
||||
float NewR = A.x * B.x;
|
||||
float NewG = A.y * B.y;
|
||||
float NewB = A.z * B.z;
|
||||
float NewA = A.w * B.w;
|
||||
|
||||
float NewR = r * rkOther.r;
|
||||
float NewG = g * rkOther.g;
|
||||
float NewB = b * rkOther.b;
|
||||
float NewA = a * rkOther.a;
|
||||
return CColor(NewR, NewG, NewB, NewA);
|
||||
}
|
||||
|
||||
void CColor::operator*=(const CColor& other)
|
||||
void CColor::operator*=(const CColor& rkOther)
|
||||
{
|
||||
*this = (*this * rkOther);
|
||||
}
|
||||
|
||||
CColor CColor::operator*(float other) const
|
||||
{
|
||||
float NewR = fmin( fmax(r * other, 0.f), 1.f);
|
||||
float NewG = fmin( fmax(g * other, 0.f), 1.f);
|
||||
float NewB = fmin( fmax(b * other, 0.f), 1.f);
|
||||
float NewA = fmin( fmax(a * other, 0.f), 1.f);
|
||||
return CColor(NewR, NewG, NewB, NewA);
|
||||
}
|
||||
|
||||
void CColor::operator*=(float other)
|
||||
{
|
||||
*this = (*this * other);
|
||||
}
|
||||
|
||||
CColor CColor::operator*(const float other) const
|
||||
CColor CColor::operator/(const CColor& rkOther) const
|
||||
{
|
||||
CVector4f Vec4f = ToVector4f() * other;
|
||||
return CColor(Vec4f.x, Vec4f.y, Vec4f.z, Vec4f.w);
|
||||
float NewR = (rkOther.r == 0.f) ? 0.f : r / rkOther.r;
|
||||
float NewG = (rkOther.g == 0.f) ? 0.f : g / rkOther.g;
|
||||
float NewB = (rkOther.b == 0.f) ? 0.f : b / rkOther.b;
|
||||
float NewA = (rkOther.a == 0.f) ? 0.f : a / rkOther.a;
|
||||
return CColor(NewR, NewG, NewB, NewA);
|
||||
}
|
||||
|
||||
void CColor::operator*=(const float other)
|
||||
void CColor::operator/=(const CColor& rkOther)
|
||||
{
|
||||
*this = (*this * other);
|
||||
}
|
||||
|
||||
CColor CColor::operator/(const CColor& other) const
|
||||
{
|
||||
u16 NewR = (other.r == 0) ? 0 : r / other.r;
|
||||
u16 NewG = (other.g == 0) ? 0 : g / other.g;
|
||||
u16 NewB = (other.b == 0) ? 0 : b / other.b;
|
||||
u16 NewA = (other.a == 0) ? 0 : a / other.a;
|
||||
return CColor((u8) NewR, (u8) NewG, (u8) NewB, (u8) NewA);
|
||||
}
|
||||
|
||||
void CColor::operator/=(const CColor& other)
|
||||
{
|
||||
*this = (*this / other);
|
||||
*this = (*this / rkOther);
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CColor CColor::RandomColor(bool transparent)
|
||||
CColor CColor::Integral(u8 rgba)
|
||||
{
|
||||
CColor out;
|
||||
out.r = rand() % 255;
|
||||
out.g = rand() % 255;
|
||||
out.b = rand() % 255;
|
||||
out.a = (transparent ? rand() % 255 : 0);
|
||||
out.SetIntegral(rgba);
|
||||
return out;
|
||||
}
|
||||
|
||||
CColor CColor::Integral(u8 _r, u8 _g, u8 _b, u8 _a /*= 255*/)
|
||||
{
|
||||
CColor out;
|
||||
out.SetIntegral(_r, _g, _b, _a);
|
||||
return out;
|
||||
}
|
||||
|
||||
CColor CColor::RandomColor(bool transparent)
|
||||
{
|
||||
float _r = (rand() % 255) / 255.f;
|
||||
float _g = (rand() % 255) / 255.f;
|
||||
float _b = (rand() % 255) / 255.f;
|
||||
float _a = (transparent ? (rand() % 255) / 255.f : 0);
|
||||
return CColor(_r, _g, _b, _a);
|
||||
}
|
||||
|
||||
CColor CColor::RandomLightColor(bool transparent)
|
||||
{
|
||||
CColor out;
|
||||
out.r = 127 + (rand() % 128);
|
||||
out.g = 127 + (rand() % 128);
|
||||
out.b = 127 + (rand() % 128);
|
||||
out.a = (transparent ? 127 + (rand() % 128) : 0);
|
||||
return out;
|
||||
float _r = 0.5f + (rand() % 128) / 255.f;
|
||||
float _g = 0.5f + (rand() % 128) / 255.f;
|
||||
float _b = 0.5f + (rand() % 128) / 255.f;
|
||||
float _a = (transparent ? 0.5f + ((rand() % 128) / 255.f) : 0);
|
||||
return CColor(_r, _g, _b, _a);
|
||||
}
|
||||
|
||||
CColor CColor::RandomDarkColor(bool transparent)
|
||||
{
|
||||
CColor out;
|
||||
out.r = rand() % 128;
|
||||
out.g = rand() % 128;
|
||||
out.b = rand() % 128;
|
||||
out.a = (transparent ? rand() % 128 : 0);
|
||||
return out;
|
||||
float _r = (rand() % 128) / 255.f;
|
||||
float _g = (rand() % 128) / 255.f;
|
||||
float _b = (rand() % 128) / 255.f;
|
||||
float _a = (transparent ? (rand() % 128) / 255.f : 0);
|
||||
return CColor(_r, _g, _b, _a);
|
||||
}
|
||||
|
||||
// defining predefined colors
|
||||
const CColor CColor::skRed (u32(0xFF0000FF));
|
||||
const CColor CColor::skGreen (u32(0x00FF00FF));
|
||||
const CColor CColor::skBlue (u32(0x0000FFFF));
|
||||
const CColor CColor::skYellow(u32(0xFFFF00FF));
|
||||
const CColor CColor::skPurple(u32(0xFF00FFFF));
|
||||
const CColor CColor::skCyan (u32(0x00FFFFFF));
|
||||
const CColor CColor::skWhite (u32(0xFFFFFFFF));
|
||||
const CColor CColor::skBlack (u32(0x000000FF));
|
||||
const CColor CColor::skGray (u32(0x808080FF));
|
||||
const CColor CColor::skTransparentRed (u32(0xFF000000));
|
||||
const CColor CColor::skTransparentGreen (u32(0x00FF0000));
|
||||
const CColor CColor::skTransparentBlue (u32(0x0000FF00));
|
||||
const CColor CColor::skTransparentYellow(u32(0xFFFF0000));
|
||||
const CColor CColor::skTransparentPurple(u32(0xFF00FF00));
|
||||
const CColor CColor::skTransparentCyan (u32(0x00FFFF00));
|
||||
const CColor CColor::skTransparentWhite (u32(0xFFFFFF00));
|
||||
const CColor CColor::skTransparentBlack (u32(0x00000000));
|
||||
const CColor CColor::skTransparentGray (u32(0x80808000));
|
||||
const CColor CColor::skRed (1.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skGreen (0.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skBlue (0.0f, 0.0f, 1.0f);
|
||||
const CColor CColor::skYellow(1.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skPurple(1.0f, 0.0f, 1.0f);
|
||||
const CColor CColor::skCyan (0.0f, 1.0f, 1.0f);
|
||||
const CColor CColor::skWhite (1.0f, 1.0f, 1.0f);
|
||||
const CColor CColor::skBlack (0.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skGray (0.5f, 0.5f, 0.5f);
|
||||
const CColor CColor::skTransparentRed (1.0f, 0.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skTransparentGreen (0.0f, 1.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skTransparentBlue (0.0f, 0.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skTransparentYellow(1.0f, 1.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skTransparentPurple(1.0f, 0.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skTransparentCyan (0.0f, 1.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skTransparentWhite (1.0f, 1.0f, 1.0f, 0.0f);
|
||||
const CColor CColor::skTransparentBlack (0.0f, 0.0f, 0.0f, 0.0f);
|
||||
const CColor CColor::skTransparentGray (0.5f, 0.5f, 0.5f, 0.0f);
|
||||
|
|
|
@ -3,26 +3,23 @@
|
|||
|
||||
#include <FileIO/CInputStream.h>
|
||||
#include <FileIO/COutputStream.h>
|
||||
#include "Math/CVector4f.h"
|
||||
#include "types.h"
|
||||
|
||||
class CColor
|
||||
{
|
||||
public:
|
||||
u8 r, g, b, a;
|
||||
float r, g, b, a;
|
||||
|
||||
CColor();
|
||||
CColor(CInputStream& src);
|
||||
CColor(u32 rgba);
|
||||
CColor(u8 rgba);
|
||||
CColor(u8 _r, u8 _g, u8 _b, u8 _a);
|
||||
CColor(CInputStream& src, bool Integral = false);
|
||||
CColor(float rgba);
|
||||
CColor(float _r, float _g, float _b, float _a);
|
||||
void Write(COutputStream& Output);
|
||||
CColor(float _r, float _g, float _b, float _a = 1.f);
|
||||
void SetIntegral(u8 rgba);
|
||||
void SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a = 255);
|
||||
void Write(COutputStream& Output, bool Integral = false);
|
||||
|
||||
long AsLongRGBA() const;
|
||||
long ToLongRGBA() const;
|
||||
long ToLongARGB() const;
|
||||
CVector4f ToVector4f() const;
|
||||
bool operator==(const CColor& other) const;
|
||||
bool operator!=(const CColor& other) const;
|
||||
CColor operator+(const CColor& other) const;
|
||||
|
@ -31,12 +28,14 @@ public:
|
|||
void operator-=(const CColor& other);
|
||||
CColor operator*(const CColor& other) const;
|
||||
void operator*=(const CColor& other);
|
||||
CColor operator*(const float other) const;
|
||||
void operator*=(const float other);
|
||||
CColor operator*(float other) const;
|
||||
void operator*=(float other);
|
||||
CColor operator/(const CColor& other) const;
|
||||
void operator/=(const CColor& other);
|
||||
|
||||
// Static
|
||||
static CColor Integral(u8 rgba);
|
||||
static CColor Integral(u8 _r, u8 _g, u8 _b, u8 _a = 255);
|
||||
static CColor RandomColor(bool transparent);
|
||||
static CColor RandomLightColor(bool transparent);
|
||||
static CColor RandomDarkColor(bool transparent);
|
||||
|
|
|
@ -233,8 +233,7 @@ void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, con
|
|||
glUniform2f(ScaleLoc, Scale.x, Scale.y);
|
||||
|
||||
GLuint TintLoc = mpBillboardShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = Tint.ToVector4f();
|
||||
glUniform4f(TintLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintLoc, Tint.r, Tint.g, Tint.b, Tint.a);
|
||||
|
||||
pTexture->Bind(0);
|
||||
|
||||
|
@ -263,12 +262,10 @@ void CDrawUtil::DrawLightBillboard(ELightType Type, const CColor& LightColor, co
|
|||
glUniform2f(ScaleLoc, Scale.x, Scale.y);
|
||||
|
||||
GLuint ColorLoc = mpLightBillboardShader->GetUniformLocation("LightColor");
|
||||
CVector4f Color4f = LightColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, Color4f.x, Color4f.y, Color4f.z, Color4f.w);
|
||||
glUniform4f(ColorLoc, LightColor.r, LightColor.g, LightColor.b, LightColor.a);
|
||||
|
||||
GLuint TintLoc = mpLightBillboardShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = Tint.ToVector4f();
|
||||
glUniform4f(TintLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintLoc, Tint.r, Tint.g, Tint.b, Tint.a);
|
||||
|
||||
CTexture *pTexA = GetLightTexture(Type);
|
||||
CTexture *pTexB = GetLightMask(Type);
|
||||
|
@ -297,8 +294,7 @@ void CDrawUtil::UseColorShader(const CColor& kColor)
|
|||
mpColorShader->SetCurrent();
|
||||
|
||||
GLuint ColorLoc = mpColorShader->GetUniformLocation("ColorIn");
|
||||
CVector4f ColorVec4 = kColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, ColorVec4.x, ColorVec4.y, ColorVec4.z, ColorVec4.w);
|
||||
glUniform4f(ColorLoc, kColor.r, kColor.g, kColor.b, kColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
|
@ -312,8 +308,7 @@ void CDrawUtil::UseColorShaderLighting(const CColor& kColor)
|
|||
glUniform1i(NumLightsLoc, CGraphics::sNumLights);
|
||||
|
||||
GLuint ColorLoc = mpColorShaderLighting->GetUniformLocation("ColorIn");
|
||||
CVector4f ColorVec4 = kColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, ColorVec4.x, ColorVec4.y, ColorVec4.z, ColorVec4.w);
|
||||
glUniform4f(ColorLoc, kColor.r, kColor.g, kColor.b, kColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
|
@ -329,8 +324,7 @@ void CDrawUtil::UseTextureShader(const CColor& TintColor)
|
|||
mpTextureShader->SetCurrent();
|
||||
|
||||
GLuint TintColorLoc = mpTextureShader->GetUniformLocation("TintColor");
|
||||
CVector4f TintVec4 = TintColor.ToVector4f();
|
||||
glUniform4f(TintColorLoc, TintVec4.x, TintVec4.y, TintVec4.z, TintVec4.w);
|
||||
glUniform4f(TintColorLoc, TintColor.r, TintColor.g, TintColor.b, TintColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
|
@ -342,8 +336,7 @@ void CDrawUtil::UseCollisionShader(const CColor& TintColor /*= CColor::skWhite*/
|
|||
LoadCheckerboardTexture(0);
|
||||
|
||||
GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = TintColor.ToVector4f();
|
||||
glUniform4f(TintColorLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintColorLoc, TintColor.r, TintColor.g, TintColor.b, TintColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
|
|
|
@ -158,16 +158,16 @@ void CGraphics::SetDefaultLighting()
|
|||
sDefaultDirectionalLights[2].Load();
|
||||
UpdateLightBlock();
|
||||
|
||||
sVertexBlock.COLOR0_Amb = CColor::skGray.ToVector4f();
|
||||
sVertexBlock.COLOR0_Amb = CColor::skGray;
|
||||
UpdateVertexBlock();
|
||||
}
|
||||
|
||||
void CGraphics::SetupAmbientColor()
|
||||
{
|
||||
if (sLightMode == eWorldLighting)
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor.ToVector4f() * sWorldLightMultiplier;
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
||||
else
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor.ToVector4f();
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
||||
}
|
||||
|
||||
void CGraphics::SetIdentityMVP()
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
/**
|
||||
* todo: should probably be replaced with a CGraphicsState class which
|
||||
* can be instantiated and is probably more safe/functional than global access.
|
||||
* also,
|
||||
* also, should probably have inline set/get functions rather than having all
|
||||
* members public so that we can track when a value is modified and maybe
|
||||
* execute extra functionality when certain values are changed
|
||||
*/
|
||||
class CGraphics
|
||||
{
|
||||
|
@ -41,9 +43,9 @@ public:
|
|||
{
|
||||
CMatrix4f TexMatrices[10];
|
||||
CMatrix4f PostMatrices[20];
|
||||
CVector4f COLOR0_Amb;
|
||||
CVector4f COLOR0_Mat;
|
||||
CVector4f COLOR1_Amb;
|
||||
CColor COLOR0_Amb;
|
||||
CColor COLOR0_Mat;
|
||||
CColor COLOR1_Amb;
|
||||
CVector4f COLOR1_Mat;
|
||||
};
|
||||
static SVertexBlock sVertexBlock;
|
||||
|
@ -51,9 +53,9 @@ public:
|
|||
// SPixelBlock
|
||||
struct SPixelBlock
|
||||
{
|
||||
CVector4f Konst[4];
|
||||
CVector4f TevColor;
|
||||
CVector4f TintColor;
|
||||
CColor Konst[4];
|
||||
CColor TevColor;
|
||||
CColor TintColor;
|
||||
};
|
||||
static SPixelBlock sPixelBlock;
|
||||
|
||||
|
@ -64,7 +66,7 @@ public:
|
|||
{
|
||||
CVector4f Position;
|
||||
CVector4f Direction;
|
||||
CVector4f Color;
|
||||
CColor Color;
|
||||
CVector4f DistAtten;
|
||||
CVector4f AngleAtten;
|
||||
};
|
||||
|
|
|
@ -46,8 +46,7 @@ void CRenderer::Init()
|
|||
{
|
||||
if (!mInitialized)
|
||||
{
|
||||
CVector4f ClearVec = mClearColor.ToVector4f();
|
||||
glClearColor(ClearVec.x, ClearVec.y, ClearVec.z, ClearVec.w);
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
mContextIndex = CGraphics::GetContextIndex();
|
||||
mInitialized = true;
|
||||
}
|
||||
|
@ -134,16 +133,11 @@ void CRenderer::SetBloom(EBloomMode BloomMode)
|
|||
mOptions &= ~eEnableBloom;
|
||||
}
|
||||
|
||||
void CRenderer::SetFont(CFont* /*pFont*/)
|
||||
{
|
||||
}
|
||||
|
||||
void CRenderer::SetClearColor(CColor Clear)
|
||||
void CRenderer::SetClearColor(const CColor& Clear)
|
||||
{
|
||||
mClearColor = Clear;
|
||||
CVector4f ClearVec = Clear.ToVector4f();
|
||||
ClearVec.w = 0.f;
|
||||
glClearColor(ClearVec.x, ClearVec.y, ClearVec.z, ClearVec.w);
|
||||
mClearColor.a = 0.f;
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
}
|
||||
|
||||
void CRenderer::SetViewportSize(u32 Width, u32 Height)
|
||||
|
@ -191,12 +185,12 @@ void CRenderer::RenderBloom()
|
|||
static const float skVOffset[6] = { -0.012275f, -0.007815f, -0.003350f,
|
||||
0.003350f, 0.007815f, 0.012275f };
|
||||
|
||||
static const CColor skTintColors[6] = { CColor((u8) 17, 17, 17, 255),
|
||||
CColor((u8) 53, 53, 53, 255),
|
||||
CColor((u8) 89, 89, 89, 255),
|
||||
CColor((u8) 89, 89, 89, 255),
|
||||
CColor((u8) 53, 53, 53, 255),
|
||||
CColor((u8) 17, 17, 17, 255) };
|
||||
static const CColor skTintColors[6] = { CColor::Integral(17, 17, 17),
|
||||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(89, 89, 89),
|
||||
CColor::Integral(89, 89, 89),
|
||||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(17, 17, 17) };
|
||||
|
||||
u32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
||||
u32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
||||
|
@ -295,9 +289,9 @@ void CRenderer::RenderSky(CModel *pSkyboxModel, const SViewInfo& ViewInfo)
|
|||
glEnable(GL_CULL_FACE);
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite;
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::UpdateVertexBlock();
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
@ -377,9 +371,7 @@ void CRenderer::ClearDepthBuffer()
|
|||
// ************ PRIVATE ************
|
||||
void CRenderer::InitFramebuffer()
|
||||
{
|
||||
CVector4f Clear = mClearColor.ToVector4f();
|
||||
Clear.w = 0.f;
|
||||
glClearColor(Clear.x, Clear.y, Clear.z, Clear.w);
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
|
|
@ -67,8 +67,7 @@ public:
|
|||
void ToggleOccluders(bool b);
|
||||
void ToggleAlphaDisabled(bool b);
|
||||
void SetBloom(EBloomMode BloomMode);
|
||||
void SetFont(CFont *pFont);
|
||||
void SetClearColor(CColor Clear);
|
||||
void SetClearColor(const CColor& Clear);
|
||||
void SetViewportSize(u32 Width, u32 Height);
|
||||
|
||||
// Render
|
||||
|
|
|
@ -36,8 +36,6 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
|||
GLuint ModelMtxLoc = pTextShader->GetUniformLocation("ModelMtx");
|
||||
GLuint ColorLoc = pTextShader->GetUniformLocation("FontColor");
|
||||
GLuint LayerLoc = pTextShader->GetUniformLocation("RGBALayer");
|
||||
CVector4f FillColor4f = FillColor.ToVector4f();
|
||||
CVector4f StrokeColor4f = StrokeColor.ToVector4f();
|
||||
mpFontTexture->Bind(0);
|
||||
smGlyphVertices.Bind();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -117,7 +115,7 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
|||
|
||||
// Draw fill
|
||||
glUniform1i(LayerLoc, GlyphLayer);
|
||||
glUniform4fv(ColorLoc, 1, &FillColor4f.x);
|
||||
glUniform4fv(ColorLoc, 1, &FillColor.r);
|
||||
smGlyphIndices.DrawElements();
|
||||
|
||||
// Draw stroke
|
||||
|
@ -129,7 +127,7 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
|||
else if (mTextureFormat == 8) StrokeLayer = GlyphLayer - 2;
|
||||
|
||||
glUniform1i(LayerLoc, StrokeLayer);
|
||||
glUniform4fv(ColorLoc, 1, &StrokeColor4f.x);
|
||||
glUniform4fv(ColorLoc, 1, &StrokeColor.r);
|
||||
smGlyphIndices.DrawElements();
|
||||
}
|
||||
|
||||
|
|
|
@ -200,21 +200,21 @@ void CLight::Load() const
|
|||
case eDirectional:
|
||||
Light->Position = CVector4f(-mDirection * 1048576.f, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
Light->AngleAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
break;
|
||||
case eSpot:
|
||||
Light->Position = CVector4f(mPosition, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = mDistAttenCoefficients;
|
||||
Light->AngleAtten = mAngleAttenCoefficients;
|
||||
break;
|
||||
case eCustom:
|
||||
Light->Position = CVector4f(mPosition, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = mDistAttenCoefficients;
|
||||
Light->AngleAtten = mAngleAttenCoefficients;
|
||||
break;
|
||||
|
|
|
@ -131,11 +131,11 @@ bool CMaterial::SetCurrent(ERenderOptions Options)
|
|||
|
||||
// Set konst inputs
|
||||
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst].ToVector4f();
|
||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst];
|
||||
|
||||
// Set color channels
|
||||
// COLOR0_Amb is initialized by the node instead of by the material
|
||||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite;
|
||||
|
||||
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
|
||||
if ((mOptions & eDepthWrite) || (Options & eNoAlpha)) glDepthMask(GL_TRUE);
|
||||
|
|
|
@ -173,7 +173,7 @@ void CMaterialCooker::WriteMaterialPrime(COutputStream& Out)
|
|||
{
|
||||
Out.WriteLong(NumKonst);
|
||||
for (u32 iKonst = 0; iKonst < NumKonst; iKonst++)
|
||||
Out.WriteLong( mpMat->Konst(iKonst).AsLongRGBA() );
|
||||
Out.WriteLong( mpMat->Konst(iKonst).ToLongRGBA() );
|
||||
}
|
||||
|
||||
// Blend Mode
|
||||
|
|
|
@ -81,7 +81,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
for (u32 iKonst = 0; iKonst < KonstCount; iKonst++)
|
||||
{
|
||||
if (iKonst >= 4) break;
|
||||
pMat->mKonstColors[iKonst] = CColor(*mpFile);
|
||||
pMat->mKonstColors[iKonst] = CColor(*mpFile, true);
|
||||
}
|
||||
if (KonstCount > 4) mpFile->Seek(0x4 * (KonstCount - 4), SEEK_CUR);
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
|||
if (Type == "CLR ")
|
||||
{
|
||||
CFourCC ClrType = mpFile->ReadLong();
|
||||
CColor ClrVal(*mpFile);
|
||||
CColor ClrVal(*mpFile, true);
|
||||
|
||||
if (ClrType == "DIFB")
|
||||
{
|
||||
|
|
|
@ -97,8 +97,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
|||
break;
|
||||
}
|
||||
case eColorProperty: {
|
||||
CVector4f color(SCLY);
|
||||
CColor v(color.x, color.y, color.z, color.w);
|
||||
CColor v(SCLY);
|
||||
pProp = new CColorProperty(v);
|
||||
break;
|
||||
}
|
||||
|
@ -334,8 +333,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
|||
|
||||
case eColorProperty: {
|
||||
CColorProperty *pColorCast = static_cast<CColorProperty*>(pProp);
|
||||
CVector4f Color(SCLY);
|
||||
pColorCast->Set(CColor(Color.x, Color.y, Color.z, Color.w));
|
||||
pColorCast->Set(CColor(SCLY));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -339,7 +339,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
|
|||
else if (mTexelFormat == eGX_C8) Pixel = DecodePixelC8(TXTR.ReadByte(), mPaletteInput);
|
||||
else if (mTexelFormat == eGX_RGB565) Pixel = DecodePixelRGB565(TXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGB5A3) Pixel = DecodePixelRGB5A3(TXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGBA8) Pixel = CColor(TXTR);
|
||||
else if (mTexelFormat == eGX_RGBA8) Pixel = CColor(TXTR, true);
|
||||
|
||||
Out.WriteLong(Pixel.ToLongARGB());
|
||||
}
|
||||
|
@ -558,25 +558,26 @@ void CTextureDecoder::ReadPixelRGB565(CInputStream& src, COutputStream& dst)
|
|||
void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst)
|
||||
{
|
||||
u16 px = src.ReadShort();
|
||||
CColor c;
|
||||
u8 r, g, b, a;
|
||||
|
||||
if (px & 0x8000) // RGB5
|
||||
{
|
||||
c.b = Extend5to8(px >> 10);
|
||||
c.g = Extend5to8(px >> 5);
|
||||
c.r = Extend5to8(px >> 0);
|
||||
c.a = 0xFF;
|
||||
b = Extend5to8(px >> 10);
|
||||
g = Extend5to8(px >> 5);
|
||||
r = Extend5to8(px >> 0);
|
||||
a = 255;
|
||||
}
|
||||
|
||||
else // RGB4A3
|
||||
{
|
||||
c.a = Extend3to8(px >> 12);
|
||||
c.b = Extend4to8(px >> 8);
|
||||
c.g = Extend4to8(px >> 4);
|
||||
c.r = Extend4to8(px >> 0);
|
||||
a = Extend3to8(px >> 12);
|
||||
b = Extend4to8(px >> 8);
|
||||
g = Extend4to8(px >> 4);
|
||||
r = Extend4to8(px >> 0);
|
||||
}
|
||||
|
||||
dst.WriteLong(c.ToLongARGB());
|
||||
u32 c = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
dst.WriteLong(c);
|
||||
}
|
||||
|
||||
void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst)
|
||||
|
@ -606,26 +607,26 @@ CColor CTextureDecoder::DecodePixelI4(u8 Byte, u8 WhichPixel)
|
|||
{
|
||||
if (WhichPixel == 1) Byte >>= 4;
|
||||
u8 px = Extend4to8(Byte);
|
||||
return CColor(px, px, px, 0xFF);
|
||||
return CColor::Integral(px, px, px);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelI8(u8 Byte)
|
||||
{
|
||||
return CColor(Byte, Byte, Byte, 0xFF);
|
||||
return CColor::Integral(Byte, Byte, Byte);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelIA4(u8 Byte)
|
||||
{
|
||||
u8 Alpha = Extend4to8(Byte >> 4);
|
||||
u8 Lum = Extend4to8(Byte);
|
||||
return CColor(Lum, Lum, Lum, Alpha);
|
||||
return CColor::Integral(Lum, Lum, Lum, Alpha);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelIA8(u16 Short)
|
||||
{
|
||||
u8 Alpha = (Short >> 8) & 0xFF;
|
||||
u8 Lum = Short & 0xFF;
|
||||
return CColor(Lum, Lum, Lum, Alpha);
|
||||
return CColor::Integral(Lum, Lum, Lum, Alpha);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream)
|
||||
|
@ -654,7 +655,7 @@ CColor CTextureDecoder::DecodePixelRGB565(u16 Short)
|
|||
u8 b = Extend5to8( (u8) (Short >> 11) );
|
||||
u8 g = Extend6to8( (u8) (Short >> 5) );
|
||||
u8 r = Extend5to8( (u8) (Short) );
|
||||
return CColor(r, g, b, 0xFF);
|
||||
return CColor::Integral(r, g, b, 0xFF);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
||||
|
@ -664,7 +665,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
|||
u8 b = Extend5to8( (u8) (Short >> 10));
|
||||
u8 g = Extend5to8( (u8) (Short >> 5));
|
||||
u8 r = Extend5to8( (u8) (Short) );
|
||||
return CColor(r, g, b, 0xFF);
|
||||
return CColor::Integral(r, g, b, 0xFF);
|
||||
}
|
||||
|
||||
else // RGB4A3
|
||||
|
@ -673,7 +674,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
|||
u8 b = Extend4to8( (u8) (Short >> 8) );
|
||||
u8 g = Extend4to8( (u8) (Short >> 4) );
|
||||
u8 r = Extend4to8( (u8) (Short) );
|
||||
return CColor(r, g, b, a);
|
||||
return CColor::Integral(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -819,9 +820,8 @@ void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32
|
|||
}
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodeDDSPixel(CInputStream&)
|
||||
CColor CTextureDecoder::DecodeDDSPixel(CInputStream& /*DDS*/)
|
||||
{
|
||||
// Not using parameter 1 (CInputStream& - DDS)
|
||||
return CColor::skWhite;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,16 +41,16 @@ void CModelNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInf
|
|||
{
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::UpdateLightBlock();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
|
||||
}
|
||||
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
LoadModelMatrix();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
|
|
|
@ -182,27 +182,28 @@ void CSceneNode::BuildLightList(CGameArea *pArea)
|
|||
void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
||||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::ELightingMode Mode = (ViewInfo.GameMode ? CGraphics::eWorldLighting : CGraphics::sLightMode);
|
||||
|
||||
if (CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode)
|
||||
switch (Mode)
|
||||
{
|
||||
case CGraphics::eNoLighting:
|
||||
// No lighting: default ambient color, no dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
break;
|
||||
|
||||
case CGraphics::eBasicLighting:
|
||||
// Basic lighting: default ambient color, default dynamic lights
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
break;
|
||||
|
||||
case CGraphics::eWorldLighting:
|
||||
// World lighting: world ambient color, node dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor;
|
||||
|
||||
for (u32 iLight = 0; iLight < mLightCount; iLight++)
|
||||
mLights[iLight]->Load();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::eBasicLighting)
|
||||
{
|
||||
// Basic lighting: default ambient color, default dynamic lights
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::eNoLighting)
|
||||
{
|
||||
// No lighting: default ambient color, no dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
break;
|
||||
}
|
||||
|
||||
CGraphics::UpdateLightBlock();
|
||||
|
|
|
@ -163,9 +163,9 @@ void CScriptNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewIn
|
|||
// Draw model if possible!
|
||||
if (mpActiveModel)
|
||||
{
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor().ToVector4f();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
|
@ -447,7 +447,7 @@ void CScriptNode::GeneratePosition()
|
|||
|
||||
CColor CScriptNode::WireframeColor() const
|
||||
{
|
||||
return CColor((u8) 12, 135, 194, 255);
|
||||
return CColor::Integral(12, 135, 194);
|
||||
}
|
||||
|
||||
CScriptObject* CScriptNode::Object() const
|
||||
|
|
|
@ -48,10 +48,10 @@ void CStaticNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewIn
|
|||
{
|
||||
if (!mpModel) return;
|
||||
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0, 0, 0, 1);
|
||||
float Multiplier = CGraphics::sWorldLightMultiplier;
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(Multiplier,Multiplier,Multiplier,1);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
|
||||
float Mul = CGraphics::sWorldLightMultiplier;
|
||||
CGraphics::sPixelBlock.TevColor = CColor(Mul,Mul,Mul);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::UpdateLightBlock();
|
||||
LoadModelMatrix();
|
||||
|
|
|
@ -201,7 +201,7 @@ void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInf
|
|||
void CDamageableTriggerExtra::Draw(ERenderOptions Options, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
|
||||
{
|
||||
LoadModelMatrix();
|
||||
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo);
|
||||
mpMat->SetCurrent(Options);
|
||||
|
||||
// Note: The plane the game renders this onto is 5x4.5, which is why we divide the tex coords by this value
|
||||
|
|
|
@ -67,8 +67,8 @@ void CDoorExtra::Draw(ERenderOptions Options, int ComponentIndex, const SViewInf
|
|||
if (mpShieldColorProp)
|
||||
Tint *= mpShieldColorProp->Get();
|
||||
|
||||
CGraphics::sPixelBlock.TintColor = Tint.ToVector4f();
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = Tint;
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "CPointOfInterestExtra.h"
|
||||
|
||||
const CColor CPointOfInterestExtra::skRegularColor ((u32) 0xFF7000FF);
|
||||
const CColor CPointOfInterestExtra::skImportantColor((u32) 0xFF0000FF);
|
||||
const CColor CPointOfInterestExtra::skRegularColor = CColor::Integral(0xFF,0x70,0x00);
|
||||
const CColor CPointOfInterestExtra::skImportantColor = CColor::Integral(0xFF,0x00,0x00);
|
||||
|
||||
CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent)
|
||||
: CScriptExtra(pInstance, pScene, pParent)
|
||||
|
|
|
@ -86,7 +86,7 @@ void CGizmo::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInf
|
|||
CGraphics::UpdateMVPBlock();
|
||||
|
||||
// Clear tint color
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite;
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
// Choose material set
|
||||
|
|
|
@ -62,7 +62,7 @@ void CModelEditorViewport::Paint()
|
|||
if (!mpActiveMaterial) return;
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
CGraphics::SetDefaultLighting();
|
||||
|
@ -79,7 +79,7 @@ void CModelEditorViewport::Paint()
|
|||
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::UpdateLightBlock();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::sMVPBlock.ViewMatrix = CMatrix4f::skIdentity;
|
||||
|
|
|
@ -47,7 +47,7 @@ void WTextureGLWidget::paintGL()
|
|||
CDrawUtil::DrawSquare(&mCheckerCoords[0].x);
|
||||
|
||||
// Make it darker
|
||||
CDrawUtil::UseColorShader(CColor((u8) 0, 0, 0, 128));
|
||||
CDrawUtil::UseColorShader(CColor::Integral(0.0f, 0.0f, 0.0f, 0.5f));
|
||||
glDepthMask(GL_FALSE);
|
||||
CDrawUtil::DrawSquare();
|
||||
|
||||
|
|
Loading…
Reference in New Issue