mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- Changed FRemapTable::AddDesaturation() to take doubles as parameters, since the C ABI always
passes doubles to functions anyway. - Fixed: FRemapTable::AddDesaturation() excluded the final entry from the loop. Also, it was less forgiving than AddColorRange, in that it did not support ranges in descending order. SVN r3875 (trunk)
This commit is contained in:
parent
a0f19fc788
commit
d28ebe543b
2 changed files with 25 additions and 17 deletions
|
@ -403,14 +403,22 @@ void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, in
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FRemapTable::AddDesaturation(int start, int end, float r1,float g1, float b1, float r2, float g2, float b2)
|
void FRemapTable::AddDesaturation(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2)
|
||||||
{
|
{
|
||||||
r1 = clamp(r1, 0.0f, 2.0f);
|
r1 = clamp(r1, 0.0, 2.0);
|
||||||
g1 = clamp(g1, 0.0f, 2.0f);
|
g1 = clamp(g1, 0.0, 2.0);
|
||||||
b1 = clamp(b1, 0.0f, 2.0f);
|
b1 = clamp(b1, 0.0, 2.0);
|
||||||
r2 = clamp(r2, 0.0f, 2.0f);
|
r2 = clamp(r2, 0.0, 2.0);
|
||||||
g2 = clamp(g2, 0.0f, 2.0f);
|
g2 = clamp(g2, 0.0, 2.0);
|
||||||
b2 = clamp(b2, 0.0f, 2.0f);
|
b2 = clamp(b2, 0.0, 2.0);
|
||||||
|
|
||||||
|
if (start > end)
|
||||||
|
{
|
||||||
|
swapvalues(start, end);
|
||||||
|
swapvalues(r1, r2);
|
||||||
|
swapvalues(g1, g2);
|
||||||
|
swapvalues(b1, b2);
|
||||||
|
}
|
||||||
|
|
||||||
r2 -= r1;
|
r2 -= r1;
|
||||||
g2 -= g1;
|
g2 -= g1;
|
||||||
|
@ -419,7 +427,7 @@ void FRemapTable::AddDesaturation(int start, int end, float r1,float g1, float b
|
||||||
g1 *= 255;
|
g1 *= 255;
|
||||||
b1 *= 255;
|
b1 *= 255;
|
||||||
|
|
||||||
for(int c = start; c < end; c++)
|
for(int c = start; c <= end; c++)
|
||||||
{
|
{
|
||||||
double intensity = (GPalette.BaseColors[c].r * 77 +
|
double intensity = (GPalette.BaseColors[c].r * 77 +
|
||||||
GPalette.BaseColors[c].g * 143 +
|
GPalette.BaseColors[c].g * 143 +
|
||||||
|
@ -443,7 +451,7 @@ void FRemapTable::AddDesaturation(int start, int end, float r1,float g1, float b
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FRemapTable::AddToTranslation(const char * range)
|
void FRemapTable::AddToTranslation(const char *range)
|
||||||
{
|
{
|
||||||
int start,end;
|
int start,end;
|
||||||
bool desaturated = false;
|
bool desaturated = false;
|
||||||
|
@ -515,39 +523,39 @@ void FRemapTable::AddToTranslation(const char * range)
|
||||||
else if (sc.TokenType == '%')
|
else if (sc.TokenType == '%')
|
||||||
{
|
{
|
||||||
// translation using RGB values
|
// translation using RGB values
|
||||||
float r1,g1,b1,r2,g2,b2;
|
double r1,g1,b1,r2,g2,b2;
|
||||||
|
|
||||||
sc.MustGetToken('[');
|
sc.MustGetToken('[');
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
r1 = float(sc.Float);
|
r1 = sc.Float;
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
|
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
g1 = float(sc.Float);
|
g1 = sc.Float;
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
|
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
b1 = float(sc.Float);
|
b1 = sc.Float;
|
||||||
sc.MustGetToken(']');
|
sc.MustGetToken(']');
|
||||||
sc.MustGetToken(':');
|
sc.MustGetToken(':');
|
||||||
sc.MustGetToken('[');
|
sc.MustGetToken('[');
|
||||||
|
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
r2 = float(sc.Float);
|
r2 = sc.Float;
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
|
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
g2 = float(sc.Float);
|
g2 = sc.Float;
|
||||||
sc.MustGetToken(',');
|
sc.MustGetToken(',');
|
||||||
|
|
||||||
sc.MustGetAnyToken();
|
sc.MustGetAnyToken();
|
||||||
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
if (sc.TokenType != TK_IntConst) sc.TokenMustBe(TK_FloatConst);
|
||||||
b2 = float(sc.Float);
|
b2 = sc.Float;
|
||||||
sc.MustGetToken(']');
|
sc.MustGetToken(']');
|
||||||
|
|
||||||
AddDesaturation(start, end, r1, g1, b1, r2, g2, b2);
|
AddDesaturation(start, end, r1, g1, b1, r2, g2, b2);
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct FRemapTable
|
||||||
void Serialize(FArchive &ar);
|
void Serialize(FArchive &ar);
|
||||||
void AddIndexRange(int start, int end, int pal1, int pal2);
|
void AddIndexRange(int start, int end, int pal1, int pal2);
|
||||||
void AddColorRange(int start, int end, int r1,int g1, int b1, int r2, int g2, int b2);
|
void AddColorRange(int start, int end, int r1,int g1, int b1, int r2, int g2, int b2);
|
||||||
void AddDesaturation(int start, int end, float r1,float g1, float b1, float r2, float g2, float b2);
|
void AddDesaturation(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2);
|
||||||
void AddToTranslation(const char * range);
|
void AddToTranslation(const char * range);
|
||||||
int StoreTranslation();
|
int StoreTranslation();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue