//------------------------------------------------------------------------------------
// irr::video::IImageWriter binding wrapper
//------------------------------------------------------------------------------------

class BMXIImageWriter : public IImageWriter
{
public:

	BMXBinder binder;

	bool (*BMXIImageWriter_writeImage)(s32 binding,IWriteFile *file,IImage *image,u32 param);
	bool (*BMXIImageWriter_isAWriteableFileExtension)(s32 binding,const c8 *fileName);

	BMXBinder* getBinder()
	{
		return &binder;
	}

	BMXIImageWriter() : IImageWriter()
	{
		BMXIImageWriter_writeImage=0;
		BMXIImageWriter_isAWriteableFileExtension=0;
	}

	//! write image to file
	bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) const
	{
		if (BMXIImageWriter_writeImage)
			return BMXIImageWriter_writeImage(binder.binding,file,image,param);
		else return false;
	}
	
	bool isAWriteableFileExtension(const io::path& filename) const
	{
		if (BMXIImageWriter_isAWriteableFileExtension)
			return BMXIImageWriter_isAWriteableFileExtension(binder.binding, filename.c_str());
		else return false;
	}
};

extern "C"
{
	BMXBinder* IrrVideo_BMXIImageWriter_getBinder(BMXIImageWriter* sa)
	{
		if (sa)
			return sa->getBinder();
		else return 0;
	}
	
	BMXIImageWriter* IrrVideo_BMXIImageWriter_new()
	{
		return new BMXIImageWriter();
	}

	void IrrVideo_BMXIImageWriter_bindWriteImage(BMXIImageWriter* sa, bool (*bind_writeImage)(s32 binding,IWriteFile *file, IImage *image,u32 param))
	{
		if (sa)
			sa->BMXIImageWriter_writeImage=bind_writeImage;
	}

	void IrrVideo_BMXIImageWriter_bindIsAWriteableFileExtension(BMXIImageWriter* sa, bool (*bind_isAWriteableFileExtension)(s32 binding,const c8* filename))
	{
		if (sa)
			sa->BMXIImageWriter_isAWriteableFileExtension=bind_isAWriteableFileExtension;
	}
	
// new technique.  use the parent class "C" functions
/*
	bool IrrVideo_BMXIImageWriter_writeImage(BMXIImageWriter* sa,IWriteFile *file, IImage *image)
	{
		if (sa)
			return sa->writeImage(file,image);
		else return false;
	}
	
	bool IrrVideo_BMXIImageWriter_isAWriteableFileExtension(BMXIImageWriter* sa,const c8* filename)
	{
		if (sa)
			return sa->isAWriteableFileExtension(filename);
		else return false;
	}
*/

}

