//------------------------------------------------------------------------------------
// irr::video::SColor function wrappers
//------------------------------------------------------------------------------------

extern "C"
{

	u16 IrrVideo_Func_RGB16(u32 r, u32 g, u32 b)
	{
		return RGB16(r,g,b);
	}
	
	u16 IrrVideo_Func_RGBA16(u32 r, u32 g, u32 b, u32 a)
	{
		return RGBA16(r,g,b,a);
	}
	
	u16 IrrVideo_Func_RGB16from16(u16 r, u16 g, u16 b)
	{
		return RGB16from16(r,g,b);
	}
	
	u16 IrrVideo_Func_X8R8G8B8toA1R5G5B5(u32 color)
	{
		return X8R8G8B8toA1R5G5B5(color);
	}

	u16 IrrVideo_Func_A8R8G8B8toR5G6B5(u32 color) 
	{
		return A8R8G8B8toR5G6B5(color);
	}
	
	u32 IrrVideo_Func_getAlpha(u16 color)
	{
		return getAlpha(color);
	}
	
	u32 IrrVideo_Func_getRed(u16 color)
	{
		return getRed(color);
	}
	
	u32 IrrVideo_Func_getGreen(u16 color)
	{
		return getGreen(color);
	}
	
	u32 IrrVideo_Func_getBlue(u16 color)
	{
		return getBlue(color);
	}
		
	u32 IrrVideo_Func_A1R5G5B5toA8R8G8B8(u16 color)
	{
		return A1R5G5B5toA8R8G8B8(color);
	}
	
	u16 IrrVideo_Func_A8R8G8B8toA1R5G5B5(u32 color)
	{
		return A8R8G8B8toA1R5G5B5(color);
	}
	
	u32 IrrVideo_Func_R5G6B5toA8R8G8B8(u16 color)
	{
		return R5G6B5toA8R8G8B8(color);
	}

	u16 IrrVideo_Func_R5G6B5toA1R5G5B5(u16 color)
	{
		return R5G6B5toA1R5G5B5(color);
	}

	u16 IrrVideo_Func_A1R5G5B5toR5G6B5(u16 color)
	{
		return A1R5G5B5toR5G6B5(color);
	}
	
	s32 IrrVideo_Func_getAverage(s16 color)
	{
		return getAverage(color);
	}
}

//------------------------------------------------------------------------------------
// irr::video::SColor wrappers
//------------------------------------------------------------------------------------

extern "C" 
{

	SColor* IrrVideo_SColor_new()
	{
		return new SColor();
	}
	
	SColor* IrrVideo_SColor_newFromVals(u32 a, u32 r, u32 g, u32 b)
	{
		return new SColor(a,r,g,b);
	}
	
	SColor* IrrVideo_SColor_newFromColorVal(u32 clr)
	{
		return new SColor(clr);
	}
	
	void IrrVideo_SColor_del(SColor* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	u32 IrrVideo_SColor_getAlpha(SColor* color)
	{
		if (color)
			return color->getAlpha();
		else
			return 0;
	}
	
	u32 IrrVideo_SColor_getRed(SColor* color)
	{
		if (color)
			return color->getRed();
		else
			return 0;
	}
	
	u32 IrrVideo_SColor_getGreen(SColor* color)
	{
		if (color)
			return color->getGreen();
		else
			return 0;
	}
	
	u32 IrrVideo_SColor_getBlue(SColor* color)
	{
		if (color)
			return color->getBlue();
		else
			return 0;
	}
	
	void IrrVideo_SColor_setAlpha(SColor* color,u32 a)
	{
		if (color)
			color->setAlpha(a);
	}
	
	void IrrVideo_SColor_setRed(SColor* color,u32 r)
	{
		if (color)
			color->setRed(r);
	}
	
	void IrrVideo_SColor_setGreen(SColor* color,u32 g)
	{
		if (color)
			color->setGreen(g);
	}
	
	void IrrVideo_SColor_setBlue(SColor* color,u32 b)
	{
		if (color)
			color->setBlue(b);
	}
	
	u16 IrrVideo_SColor_toA1R5G5B5(SColor* color)
	{
		if (color)
			return color->toA1R5G5B5();
		else
			return 0;
	}
	
	// oglColor is a 4char array
	void IrrVideo_SColor_toOpenGLColor(SColor* color,u8* oglColor)
	{
		if (color)
			color->toOpenGLColor(oglColor);
	}
	
	void IrrVideo_SColor_set(SColor* color,u32 a, u32 r, u32 g, u32 b)
	{
		if (color)
			return color->set(a,r,g,b);
	}
	
	bool IrrVideo_SColor_EqEq(SColor* color,SColor* other)
	{
		if (color)
			return (*color==*other);
		else
			return false;
	}
	
	bool IrrVideo_SColor_NotEq(SColor* color,SColor* other)
	{
		if (color)
			return (*color!=*other);
		else
			return true;
	}
	
	SColor* IrrVideo_SColor_getInterpolated(SColor* color,SColor* other,f32 d)
	{
		if (color)
			return new SColor(color->getInterpolated(*other,d));
		else
			return 0;
	}
	
	u32 IrrVideo_SColor_getColor(SColor* color)
	{
		if (color)
			return color->color;
		else
			return 0;
	}
	
	f32 IrrVideo_SColor_getLuminance(SColor* color)
	{
		if (color)
			return color->getLuminance();
		else return 0;
	}

	u32 IrrVideo_SColor_getAverage(SColor* color)
	{
		if (color)
			return color->getAverage();
		else return 0;
	}

	SColor* IrrVideo_SColor_getInterpolated_quadratic(SColor* color,const SColor& c1, const SColor& c2, const f32 d)
	{
		if (color)
			return new SColor(color->getInterpolated_quadratic(c1,c2,d));
		else return 0;
	}

	// must delete
	SColor* IrrVideo_SColor_plus(SColor* color,SColor* other)
	{
		if (color)
			return new SColor(*color + *other);
		else return 0;
	}

	f32 IrrVideo_SColor_getLightness(SColor* color)
	{
		if (color)
			return color->getLightness();
		else return -1;
	}
}

//------------------------------------------------------------------------------------
// irr::video::SColorf wrappers
//------------------------------------------------------------------------------------

extern "C" 
{

	SColorf* IrrVideo_SColorf_new()
	{
		return new SColorf();
	}
	
	SColorf* IrrVideo_SColorf_newFromRGB(f32 r, f32 g, f32 b)
	{
		return new SColorf(r,g,b);
	}
	
	SColorf* IrrVideo_SColorf_newFromRGBA(f32 r, f32 g, f32 b, f32 a=1.0f)
	{
		return new SColorf(r,g,b,a);
	}
	
	SColorf* IrrVideo_SColorf_newFromSColor(SColor* clr)
	{
		return new SColorf(*clr);
	}
	
	void IrrVideo_SColorf_del(SColorf* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	SColor* IrrVideo_SColorf_toSColor(SColorf* color)
	{
		if (color)
			return new SColor(color->toSColor());
	}
	
	void IrrVideo_SColorf_set(SColorf* color,f32 rr, f32 gg, f32 bb)
	{
		if (color)
			color->set(rr,gg,bb);
	}
	
	void IrrVideo_SColorf_setWithAlpha(SColorf* color,f32 aa, f32 rr, f32 gg, f32 bb)
	{
		if (color)
			color->set(aa,rr,gg,bb);
	}
	
	f32 IrrVideo_SColorf_getAlpha(SColorf* color)
	{
		if (color)
			return color->a;
		else
			return 0;
	}
	
	f32 IrrVideo_SColorf_getRed(SColorf* color)
	{
		if (color)
			return color->r;
		else
			return 0;
	}
	
	f32 IrrVideo_SColorf_getGreen(SColorf* color)
	{
		if (color)
			return color->g;
		else
			return 0;
	}
	
	f32 IrrVideo_SColorf_getBlue(SColorf* color)
	{
		if (color)
			return color->b;
		else
			return 0;
	}
	
	f32* IrrVideo_SColorf_getArray(SColorf* color)
	{
		if (color)
			return reinterpret_cast<f32*>(color);
	}
	
	SColorf* IrrVideo_SColorf_getInterpolated(SColorf* color,SColorf* other,f32 d)
	{
		if (color)
			return new SColorf(color->getInterpolated(*other,d));
		else return 0;
	}
	
	void IrrVideo_SColorf_setColorComponentValue(SColorf* color,u32 index, f32 value)
	{
		if (color)
			color->setColorComponentValue(index,value);
	}
	
	SColorf* IrrVideo_SColorf_getInterpolated_quadratic(SColorf* color,const SColorf& c1, const SColorf& c2, const f32 d)
	{
		if (color)
			return new SColorf(color->getInterpolated_quadratic(c1,c2,d));
		else return 0;
	}
}

//------------------------------------------------------------------------------------
// irr::video::SColorHSL wrappers
//------------------------------------------------------------------------------------

extern "C" 
{
	SColorHSL* IrrVideo_SColorHSL_new( f32 h = 0.f, f32 s = 0.f, f32 l = 0.f )
	{
		return new SColorHSL(h,s,l);
	}

	void IrrVideo_SColorHSL_del(SColorHSL* hsv)
	{
		if (hsv)
			delete hsv;
	}
	
	void IrrVideo_SColorHSL_toRGB(SColorHSL* hsv,SColor& color)
	{
		if (hsv)
			hsv->toRGB(color);
	}	
}