// define the BMX functions from the type
extern "C" {
	void _irrlicht_core_ILightManager_BoundOnPreRender(s32 binding, ILightSceneNode** lightList, u32 lightCount);
	void _irrlicht_core_ILightManager_BoundOnPostRender(s32 binding);
	void _irrlicht_core_ILightManager_BoundOnRenderPassPreRender(s32 binding, E_SCENE_NODE_RENDER_PASS renderPass);
	void _irrlicht_core_ILightManager_BoundOnRenderPassPostRender(s32 binding, E_SCENE_NODE_RENDER_PASS renderPass);
	void _irrlicht_core_ILightManager_BoundOnNodePreRender(s32 binding, ISceneNode* node);
	void _irrlicht_core_ILightManager_BoundOnNodePostRender(s32 binding, ISceneNode* node);
}

class BMXILightManager : public ILightManager
{
public:

	BMXBinder binder;

	BMXBinder* getBinder()
	{
		return &binder;
	}

	void OnPreRender(core::array<ILightSceneNode*> & lightList) 
	{
		// convert lightList to an array of ptrs for passing on
		_irrlicht_core_ILightManager_BoundOnPreRender(binder.binding, lightList.pointer(), lightList.size());
	}

	void OnPostRender(void) 
	{
		_irrlicht_core_ILightManager_BoundOnPostRender(binder.binding);
	}

	void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) 
	{
		_irrlicht_core_ILightManager_BoundOnRenderPassPreRender(binder.binding, renderPass);	
	}

	void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) 
	{
		_irrlicht_core_ILightManager_BoundOnRenderPassPostRender(binder.binding, renderPass);
	}

	void OnNodePreRender(ISceneNode* node) 
	{
		_irrlicht_core_ILightManager_BoundOnNodePreRender(binder.binding, node);
	}

	void OnNodePostRender(ISceneNode* node) 
	{
		_irrlicht_core_ILightManager_BoundOnNodePostRender(binder.binding, node);
	}
};

extern "C"
{
	BMXILightManager* IrrScene_BMXILightManager_new()
	{
		return new BMXILightManager();
	}

	BMXBinder* IrrScene_BMXILightManager_getBinder(BMXILightManager* sa)
	{
		if (sa)
			return sa->getBinder();
		else return 0;
	}

	bool IrrScene_BMXILightManager_drop(IImageWriter* unk)
	{
		if (unk)
			return unk->drop();
		else return 0;
	}
	
	const c8* IrrScene_BMXILightManager_getDebugName(IImageWriter* unk)
	{
		if (unk)
			return unk->getDebugName();
		else return "";
	}
	
	void IrrScene_BMXILightManager_grab(IImageWriter* unk)
	{
		if (unk)
			unk->grab();
	}
}

