Ykkrosh
2f53eea71a
Color: Moved SColor* structs into SColor.h, so they can be used without indirectly including CVector[34]D. Terrain: Added 'base colour', for the Actor Viewer to be able to modulate the colour of normally-white terrain. Removed some "using namespace std" (because it doesn't make the code easier to read, and it defeats the point of namespaces, and the rest of the code doesn't do it). This was SVN commit r4392.
43 lines
889 B
C++
43 lines
889 B
C++
#include "precompiled.h"
|
|
|
|
#include "graphics/Color.h"
|
|
|
|
#include "maths/MathUtil.h"
|
|
#include "graphics/SColor.h"
|
|
|
|
static u32 fallback_ConvertRGBColorTo4ub(const RGBColor& src)
|
|
{
|
|
SColor4ub result;
|
|
result.R=clamp(int(src.X*255),0,255);
|
|
result.G=clamp(int(src.Y*255),0,255);
|
|
result.B=clamp(int(src.Z*255),0,255);
|
|
result.A=0xff;
|
|
return *(u32*)&result;
|
|
}
|
|
|
|
// on IA32, this is replaced by an SSE assembly version in ia32.cpp
|
|
u32 (*ConvertRGBColorTo4ub)(const RGBColor& src) = fallback_ConvertRGBColorTo4ub;
|
|
|
|
|
|
// Assembler-optimized function for color conversion
|
|
#if CPU_IA32
|
|
extern "C" u32 sse_ConvertRGBColorTo4ub(const RGBColor& src);
|
|
#endif
|
|
|
|
void ColorActivateFastImpl()
|
|
{
|
|
if(0)
|
|
{
|
|
}
|
|
#if CPU_IA32
|
|
else if (ia32_cap(IA32_CAP_SSE))
|
|
{
|
|
ConvertRGBColorTo4ub = sse_ConvertRGBColorTo4ub;
|
|
}
|
|
#endif
|
|
else
|
|
{
|
|
debug_printf("No SSE available. Slow fallback routines will be used.\n");
|
|
}
|
|
}
|