#pragma once

#include "deferredshadowtechnique.h"
#include "..\DXFunctions\DLLInterface.h"
#include "..\DXFunctions\RenderList.h"
#include "..\DXFunctions\Bound.h"

#include "ShadowMapping.h"
#include "..\GameGUI\GUIElement.h"

class Label;

class DeferredShadowZTiled : public DeferredShadowTechnique
{
	RenderList	m_RLCurr; //current tile, cause it is 
	RenderList	m_RLNext[2]; //other half of current tile -> sum of all further tiles, 
	//2 sets because it will be recursively be splitted in RLCurr and RLNext

	int m_TileCount;
	int m_MaxTilePasses;
	float m_Tiling;
	SMJITTERTYPE m_JitterType;
	bool m_AutoTiling;
	float m_MaxSampleSize;
	bool m_NoConf;
	bool m_ExactFilter;
	float m_ExactSize;
	//bool m_UseLispSM;

	ShaderEffect* m_FXConfShadow;

	Label* m_lbAutoTilingTiles;

	//splitts renderlist all in current and next part
	void GetTileShadowCasters(const Frustum& f, const RenderList& all, RenderList& curr, RenderList& next);
	
	//static void OnLispSMCheck(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnJitterTypeChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnTilesChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnMaxTilePassesChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnTilingChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnAutoTilingChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnMaxSampleSizeChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnExactFilterChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnExactSizeChanged(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnNoConfidence(GUIElement* const sender, const GUIEVENT evnt, void* pData);
		
	void CreateMenu(void);

public:
	DeferredShadowZTiled(ShadowApp* const pApp);
	~DeferredShadowZTiled(void);

	void RenderShadowMask(void);

	void UpdateInput(void);
};
