
//
// Asura_Projector_System.h
//
// Created by Dave Reed - 05/01/2007 
// 
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_PROJECTOR_SYSTEM_H__
#define __ASURA_PROJECTOR_SYSTEM_H__

#ifdef ASURA_TARGET_SM3

#include "Core/Asura_Handle.h"
#include "Core/Asura_Mempool.h"
#include "Projectors/Asura_Projector.h"

template<typename T> class Asura_TrackingHandlePool;

#if !defined(ASURA_MAX_NO_OF_LOCAL_PROJECTORS)
#define ASURA_MAX_NO_OF_LOCAL_PROJECTORS 64
#endif	// !defined(ASURA_MAX_NO_OF_LOCAL_PROJECTORS)

struct Asura_MakeLocalProjectorData
{
	Asura_Bounding_Box *pxBB;
	bool			    bLightsOnly;
};

typedef Asura_TrackingHandlePool_Iterator<Asura_Projector> Asura_Projector_Iterator;

class Asura_Projector_System
{
public:
	static void Initialise(void);	
	static void Shutdown(void);
	static void Reset(void);

	static void Update(void);
	static void Render(bool bWithDarkeningShadows, bool bWithRealShadows, bool bWithNoShadows);

	static Asura_Projector*	CreateProjector(void);
	static void				DestroyProjector(const Asura_Projector* pxProjector);
	static Asura_Projector* GetProjectorPointer(Asura_Handle iHandle);

	static int              MakeLocalProjectorList(Asura_Bounding_Box xBB);
	static Asura_Projector**GetLocalProjectorList(void) {return &s_apxLocalProjectors[0];}
	
	static Asura_Projector_Iterator GetIterator();

private:	
	static Asura_TrackingHandlePool<Asura_Projector>*	s_pxProjectorList;
	#if !defined( ASURA_USE_NEW_VISIBILITY_SYSTEM )
	static Asura_Bounding_Box							s_xBBOfAllVisibleModules;
	#endif
	static bool											s_bWithDarkeningShadows;
	static bool											s_bWithRealShadows;
	static bool											s_bWithNoShadows;

	static void MakeLocalProjectorListCallback(Asura_Projector* pxProjector, void *pxData);
	static void RenderCallback(Asura_Projector* pxProjector);

	static u_int			s_uNumberOfLocalProjectors;
	static Asura_Projector*	s_apxLocalProjectors[ASURA_MAX_NO_OF_LOCAL_PROJECTORS];

	// Private functions...
	static void Platform_Initialise(void);	
	static void Platform_Shutdown(void);
	static void Platform_Reset(void);

	static void Platform_BeginRender(void);
	static void Platform_RenderProjector(Asura_Projector *pxProjector);
	static void Platform_EndRender(void);
};



#endif //#ifdef ASURA_TARGET_SM3
#endif //__ASURA_PROJECTOR_SYSTEM_H__
