//------------------------------------------------------------------------------------
// irr::video::SMaterial wrappers
//
// WARNING: do NOT release handles obtained via the get() methods
//------------------------------------------------------------------------------------

extern "C"
{

	SMaterial* IrrVideo_SMaterial_new()
	{
		return new SMaterial();
	}

	SMaterial* IrrVideo_SMaterial_newFromMaterial(SMaterial* other)
	{
		return new SMaterial(*other);
	}
	
	void IrrVideo_SMaterial_del(SMaterial* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	s32 IrrVideo_SMaterial_getMaterialType(SMaterial* mat)
	{
		if (mat)
			return mat->MaterialType;
		else 
			return -1;
	}
	
	void IrrVideo_SMaterial_setMaterialType(SMaterial* mat,E_MATERIAL_TYPE type)
	{
		if (mat)
			mat->MaterialType=type;
	}
	
	f32 IrrVideo_SMaterial_getMaterialTypeParam(SMaterial* mat)
	{
		if (mat)
			return mat->MaterialTypeParam;
		else return -1.0f;
	}
	
	void IrrVideo_SMaterial_setMaterialTypeParam(SMaterial* mat,f32 typeparam)
	{
		if (mat)
			mat->MaterialTypeParam=typeparam;
	}
	
	f32 IrrVideo_SMaterial_getMaterialTypeParam2(SMaterial* mat)
	{
		if (mat)
			return mat->MaterialTypeParam2;
		else return -1.0f;
	}
	
	void IrrVideo_SMaterial_setMaterialTypeParam2(SMaterial* mat,f32 typeparam)
	{
		if (mat)
			mat->MaterialTypeParam2=typeparam;
	}
	
	SColor* IrrVideo_SMaterial_getAmbientColor(SMaterial* mat)
	{
		if (mat)
			return &mat->AmbientColor;
		else
			return 0;
	}
	SColor* IrrVideo_SMaterial_getDiffuseColor(SMaterial* mat)
	{
		if (mat)
			return &mat->DiffuseColor;
		else
			return 0;
	}
	SColor* IrrVideo_SMaterial_getEmissiveColor(SMaterial* mat)
	{
		if (mat)
			return &mat->EmissiveColor;
		else
			return 0;
	}
	SColor* IrrVideo_SMaterial_getSpecularColor(SMaterial* mat)
	{
		if (mat)
			return &mat->SpecularColor;
		else
			return 0;
	}
	
	f32 IrrVideo_SMaterial_getShininess(SMaterial* mat)
	{
		if (mat)
			return mat->Shininess;
		else
			return 0.0f;
	}
	
	void IrrVideo_SMaterial_setShininess(SMaterial* mat,f32 newshine)
	{
		if (mat)
			mat->Shininess=newshine;
	}

	f32 IrrVideo_SMaterial_getThickness(SMaterial* mat)
	{
		if (mat)
			return mat->Thickness;
		else
			return 0.0f;
	}
	
	void IrrVideo_SMaterial_setThickness(SMaterial* mat,f32 newthick)
	{
		if (mat)
			mat->Thickness=newthick;
	}
	
	bool IrrVideo_SMaterial_getWireframe(SMaterial* mat)
	{
		if (mat)
			return mat->Wireframe;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setWireframe(SMaterial* mat,bool bWireFrame)
	{
		if (mat)
			mat->Wireframe=bWireFrame;
	}
	
	bool IrrVideo_SMaterial_getPointCloud(SMaterial* mat)
	{
		if (mat)
			return mat->PointCloud;
		else return false;
	}
	
	void IrrVideo_SMaterial_setPointCloud(SMaterial* mat,bool bPointCloud)
	{
		if (mat)
			mat->PointCloud=bPointCloud;
	}
	
	bool IrrVideo_SMaterial_getGouraudShading(SMaterial* mat)
	{
		if (mat)
			return mat->GouraudShading;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setGouraudShading(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->GouraudShading=bNewVal;
	}
	
	bool IrrVideo_SMaterial_getLighting(SMaterial* mat)
	{
		if (mat)
			return mat->Lighting;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setLighting(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->Lighting=bNewVal;
	}
	
	char IrrVideo_SMaterial_getZBuffer(SMaterial* mat)
	{
		if (mat)
			return mat->ZBuffer;
		else return 0;
	}
	
	void IrrVideo_SMaterial_setZBuffer(SMaterial* mat,char NewVal)
	{
		if (mat)
			mat->ZBuffer = NewVal;
	}
	
	bool IrrVideo_SMaterial_getZWriteEnable(SMaterial* mat)
	{
		if (mat)
			return mat->ZWriteEnable;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setZWriteEnable(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->ZWriteEnable=bNewVal;
	}
	
	bool IrrVideo_SMaterial_getBackfaceCulling(SMaterial* mat)
	{
		if (mat)
			return mat->BackfaceCulling;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setBackfaceCulling(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->BackfaceCulling=bNewVal;
	}
	
	
	bool IrrVideo_SMaterial_getFogEnable(SMaterial* mat)
	{
		if (mat)
			return mat->FogEnable;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setFogEnable(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->FogEnable=bNewVal;
	}
	
	bool IrrVideo_SMaterial_getNormalizeNormals(SMaterial* mat)
	{
		if (mat)
			return mat->NormalizeNormals;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setNormalizeNormals(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->NormalizeNormals=bNewVal;
	}
	
	bool IrrVideo_SMaterial_getFlag(SMaterial* mat,E_MATERIAL_FLAG flag)
	{
		if (mat)
			return mat->getFlag(flag);
		else return false;
	}
	
	void IrrVideo_SMaterial_setFlag(SMaterial* mat,E_MATERIAL_FLAG flag,bool bNewVal)
	{
		if (mat)
			mat->setFlag(flag,bNewVal);
	}
		
	ITexture* IrrVideo_SMaterial_getTexture(SMaterial* mat,u32 idx)
	{
		if (mat)
			return mat->getTexture(idx);
		else
			return 0;
	}
	
	void IrrVideo_SMaterial_setTexture(SMaterial* mat,u32 idx,ITexture* tex)
	{
		if (mat)
			mat->setTexture(idx,tex);
	}
	
	SMaterial* IrrVideo_SMaterial_SetEq(SMaterial* mat,const SMaterial& other)
	{
		*mat=other;
		return mat;
	}
	
	bool IrrVideo_SMaterial_NotEq(SMaterial* mat,const SMaterial& other)
	{
		if (mat)
			return (*mat!=other);
		else return false;
	}
	
	void IrrVideo_SMaterial_setTextureMatrix(SMaterial* mat,u32 i, const core::matrix4& matrix)
	{
		if (mat)
			mat->setTextureMatrix(i,matrix);
	}

	matrix4* IrrVideo_SMaterial_getTextureMatrix(SMaterial* mat,u32 i)
	{
		if (mat)
			return &mat->getTextureMatrix(i);
		else return 0;
	}
	
	bool IrrVideo_SMaterial_isTransparent(SMaterial* mat)
	{
		if (mat)
			return mat->isTransparent();
		else return false;
	}

	bool IrrVideo_SMaterial_getFrontfaceCulling(SMaterial* mat)
	{
		if (mat)
			return mat->FrontfaceCulling;
		else
			return false;
	}
	
	void IrrVideo_SMaterial_setFrontfaceCulling(SMaterial* mat,bool bNewVal)
	{
		if (mat)
			mat->FrontfaceCulling=bNewVal;
	}
	
	u8 IrrVideo_SMaterial_getAntiAliasing(SMaterial* mat) 
	{
		if (mat)
			return mat->AntiAliasing;
		else return 0;
	}
	
	void IrrVideo_SMaterial_setAntiAliasing(SMaterial* mat,u8 NewVal)
	{
		if (mat)
			mat->AntiAliasing = NewVal;
	}

	u8 IrrVideo_SMaterial_getColorMask(SMaterial* mat) 
	{
		if (mat)
			return mat->ColorMask;
		else return 0;
	}
	
	void IrrVideo_SMaterial_setColorMask(SMaterial* mat,u8 NewVal)
	{
		if (mat)
			mat->ColorMask = NewVal;
	}

	u8 IrrVideo_SMaterial_getColorMaterial(SMaterial* mat) 
	{
		if (mat)
			return mat->ColorMaterial;
		else return 0;
	}
	
	void IrrVideo_SMaterial_setColorMaterial(SMaterial* mat, u8 NewVal)
	{
		if (mat)
			mat->ColorMaterial = NewVal;
	}	
	
	s32 get_MATERIAL_MAX_TEXTURES() 
	{
		return MATERIAL_MAX_TEXTURES;
	}

	// do not delete
	SMaterialLayer* IrrVideo_SMaterial_getTextureLayer(SMaterial* mat, u32 layer) 
	{
		if (mat) 
			return &mat->TextureLayer[layer];
		else return 0;
	}

}	

