0ad/source/graphics/Color.cpp
janwas 1ead202b24 # add CppDoc comments; prepare for automated testing
ia32: prepend CPUCap enum names and rdtsc with ia32 to avoid conflicts.
move all self tests into separate headers as required for Cxxtest.
adts: remove some dead code.

add CppDoc comments to debug, lib (with heavy cleanup), tex, tex_codec,
snd_mgr
slight improvements to path

tex: refactor; split out tex_decode and encode to allow self-test

This was SVN commit r3911.
2006-05-31 04:01:59 +00:00

42 lines
854 B
C++

#include "precompiled.h"
#include "MathUtil.h"
#include "graphics/Color.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");
}
}