/*
 * $Id: rendermodule.h 4270 2016-11-06 11:02:47Z antonin.misek-skoda-auto.cz $
 *
 * Description  : One line description of file.
 * Author       : Vaclav Kyba <mail/Jabber: vaseo1@gmail.com>  <ICQ: 98576293>
 *
 * Purpose      :
 *     Long description of what the file is for.
 */


#ifndef __RENDERMODULE_H__
#define __RENDERMODULE_H__

#include "scenemodule.h"
#include "framerate.h"
#include "VrutApi.h"

namespace VRUT
{
	///Render type module - abstract
	class VRUT_CORE_API RenderModule : public SceneModule
	{
	protected:
		bool resizeUpdate;
		///Creates the GUI table containing the render passes
		void createRenderPassGUITable();
		///Frame rate
		FrameRate frameRate;
		///Camera node ID
		NODE_ID cameraID;
		///Active stereo
		bool activeStereo;
		///\c cameraID parameter identifier
		Parameter::ParameterIdentifier cameraIDParamID;

		bool renderTargetMapMember;

		void RegisterCameraGUI()
		{
			// Similar to ManipModule::RegisterNodeIDGUI
			REGISTER_PARAM_GUI_NODEID(cameraIDParamID, wxT("cameraID"), cameraID, sceneID, SceneNode::CreateClassMask<Camera>(), wxT("ID of camera to render."));
		}

		///Process render event - \c Module overload
		virtual void processEvent(Event * evt);

	public:

		///Module's own render target data
		RenderTarget renderTarget;

		///Class constructor
		RenderModule(const MODULE_ID & _id, const wxString & _name, unsigned _type, Kernel * _kernel)
			: SceneModule(_id, _name, (_type | MODULE_TYPE_RENDER), _kernel), resizeUpdate(false), cameraID(NODE_ID_NONE), renderTargetMapMember(false), renderTarget()
		{
			REGISTER_LISTENER(Event::EVT_SCENE_CAM_PROJECTION_CHANGED);
			REGISTER_LISTENER(Event::EVT_RENDER_WIN_RESIZED);
			RegisterCameraGUI();
			activeStereo = false;
		}

		///Class destructor
		virtual ~RenderModule()
		{
		}

		///Get associated camera
		NODE_ID GetCameraID() const
		{
			return cameraID;
		}

		///Main draw method
		virtual void Draw();
		///Deinitialize and release render data
		///If called explicitly, be sure to set GLContext associated with window/module
		virtual void Deinitialize() = 0;

		///Active or deactive active stereo rendering
		void setActiveStereo(bool isEnabled)
		{
			activeStereo = isEnabled;
		}
	};
}

#endif
