For the missing functions :
Code: Select all
u32 PremultiplyAlpha(u32 color)
{
u32 a = (color>>24)/* & 0xff*/ + 1;
u32 r = (a*((color>>16) & 0xff))>>8;
u32 g = (a*((color>>8) & 0xff))>>8;
u32 b = (a*(color & 0xff))>>8;
return (--a<<24) | (r<<16) | (g<<8) | b;
}
void PremultiplyAlpha(irr::video::ITexture* texture)
{
if(!texture || texture->getColorFormat() != irr::video::ECF_A8R8G8B8)
return;
u32* color = (u32*)texture->lock();
const irr::core::dimension2d<u32>& dim = texture->getSize();
u32 size = dim.Height*dim.Width;
do
{
*color = PremultiplyAlpha(*color);
++color;
}while (--size);
texture->unlock();
}
class MathUtils
{
public:
static float Gaussian(float x, float mu, float sigma)
{
return exp( -(((x-mu)/(sigma))*((x-mu)/(sigma)))/2.0f );
}
}
Code: Select all
typedef core::rect<s32> Rectangle2;
For example : I read a text file encoded in unicode :
Code: Select all
FILE* file = fopen(path, "r, ccs=UNICODE");
// Then anything I read as wchars will be used correctly in irrlicht and can be used with the TTF font
wchar_t line[2048];
while (fgetws(line, 2048, file) != NULL)
{
core::stringw str(line);
}
[...]