mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 01:01:25 +03:00
Fixed a Color::Blend, it was having problems with the floating point precision.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#ifndef EE_OPENGL_HPP
|
||||
#define EE_OPENGL_HPP
|
||||
|
||||
#ifdef EE_64BIT
|
||||
#include <eepp/declares.hpp>
|
||||
|
||||
#if 1 == EE_USE_DOUBLES
|
||||
#define GL_FP GL_DOUBLE
|
||||
#else
|
||||
#define GL_FP GL_FLOAT
|
||||
|
||||
@@ -209,6 +209,8 @@ public:
|
||||
return eeColorAf( red, green, blue, alpha );
|
||||
}
|
||||
|
||||
#define EE_COLOR_BLEND_FTOU8(color) (Uint8)( color == 1.f ? 255 : (color * 255.99f))
|
||||
|
||||
/** Blend a source color to destination color */
|
||||
static inline eeColorA Blend( eeColorA src, eeColorA dst ) {
|
||||
eeColorAf srcf( (eeFloat)src.Red / 255.f, (eeFloat)src.Green / 255.f, (eeFloat)src.Blue / 255.f, (eeFloat)src.Alpha / 255.f );
|
||||
@@ -218,11 +220,7 @@ public:
|
||||
eeFloat green = ( srcf.Green * srcf.Alpha + dstf.Green * dstf.Alpha * ( 1.f - srcf.Alpha ) ) / alpha;
|
||||
eeFloat blue = ( srcf.Blue * srcf.Alpha + dstf.Blue * dstf.Alpha * ( 1.f - srcf.Alpha ) ) / alpha;
|
||||
|
||||
return eeColorA( ((Uint8)(eefloor(red == 1.f ? 255 : red * 256.f))),
|
||||
((Uint8)(eefloor(green == 1.f ? 255 : green * 256.f))),
|
||||
((Uint8)(eefloor(blue == 1.f ? 255 : blue * 256.f))),
|
||||
((Uint8)(eefloor(alpha == 1.f ? 255 : alpha * 256.f)))
|
||||
);
|
||||
return eeColorA( EE_COLOR_BLEND_FTOU8(red), EE_COLOR_BLEND_FTOU8(green), EE_COLOR_BLEND_FTOU8(blue), EE_COLOR_BLEND_FTOU8(alpha) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1433,8 +1433,8 @@ void cEETest::Input() {
|
||||
eeFloat nmX = Mousef.x + mAxisX;
|
||||
eeFloat nmY = Mousef.y + mAxisY;
|
||||
|
||||
nmX = eemax( nmX, 0.f );
|
||||
nmY = eemax( nmY, 0.f );
|
||||
nmX = eemax<eeFloat>( nmX, 0 );
|
||||
nmY = eemax<eeFloat>( nmY, 0 );
|
||||
nmX = eemin( nmX, (eeFloat)EE->GetWidth() );
|
||||
nmY = eemin( nmY, (eeFloat)EE->GetHeight() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user