//===========================================================================//
// File:	renderer.hpp                                                        //
// Project: MUNGA           Brick: Renderer Manager	                       //
// Contents: Interface specification Renderer and Renderer Manager			  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 11/21/94  ECH  Initial coding.                                            //
// 01/22/95	 ECH	Added NotifyOfBecomingUninterestingEntity						  //
// 05/25/95	 CPB	Moved GetLinkedEntity into public accessability for gauges //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "Adept.hpp"
#include "VideoRenderer.hpp"

namespace Adept {

	class Entity;

	//##########################################################################
	//########################    RendererManager    ###########################
	//##########################################################################

	//-------------------------------------------------------------------------
	// The following helper classes must always be typedef'd or overriden by an
	// inheritor
	//

	typedef Receiver__ClassData	RendererManager__ClassData;
	typedef Receiver__Message		RendererManager__Message;

	//----------------- End of helper stuff -----------------

	class RendererManager:
		public Receiver
	{
		friend class Renderer;

	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef RendererManager__ClassData	ClassData;
		typedef RendererManager__Message		Message;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction, Destruction. Testing
	//
	public:
		RendererManager():
			Receiver(DefaultData),
			adoptedRenderers(NULL, true)
				{}

		void
			TestInstance();

		static RendererManager
			*Instance;

	//##########################################################################
	// Class Data support
	//
	public:
		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Renderer Creation
	//
	public:
		enum {
			ReservedForGameModelRendererType,
			VideoRendererType,
			AudioRendererType,
			RendererTypeCount
		};

		virtual int
			GetModelListSize()
				{return RendererTypeCount;}

		void
			AdoptRenderer(Renderer *renderer);

		Renderer*
			FindRenderer(int renderer_type)
				{return adoptedRenderers.Find(renderer_type);}

		virtual int
			FindRendererType(const char *renderer_name);

	protected:
		Stuff::SortedChainOf<Renderer*, int>
			adoptedRenderers;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Renderer Execution
	//
	public:
		void
			EntityIsInteresting(
				Entity *entity,
				bool render_me
			);
		void
			EntityIsUninteresting(Entity *entity);

		void
			Execute(Stuff::Time target_render_time);

		void
			ActivateRenderers();
		void
			DeactivateRenderers();
	};

}


