#pragma once
#include "..\Utilities\util.h"
#include "D3DApp.h"

class DeviceStateManager;
class DXViewPort;

class DXFUNCTIONS_API DXSwapChain : protected DXRessource
{
	DeviceStateManager* m_Device;
	LPDIRECT3DSURFACE9  m_RenderTargetRestore;
	LPDIRECT3DSURFACE9  m_DepthStencilRestore;
	LPDIRECT3DSURFACE9  m_DepthStencil;

	LPDIRECT3DSWAPCHAIN9 m_SwapChain;
	DXViewPort*			m_pViewPort;
	
	HWND					m_Wnd;
	STSelMode				m_Mode;
	D3DPRESENT_PARAMETERS	m_PresentParam;

protected:

	friend ListElement<DXSwapChain>;
	friend LList<DXSwapChain>;
	friend DeviceStateManager;

	DXSwapChain(DeviceStateManager* const device, const STSelMode& mode, const HWND hwnd);
	~DXSwapChain(void);

	void DoRestore(void);
	void DoInvalidate(void);

public:

	void Present(void);
	void Reset(const STSelMode& mode);

	void BeginScene(void);
	void EndScene(void);

	void Release(void);

	const STSelMode& GetMode(void) const {return m_Mode;}

	DXViewPort* GetViewPort(void) const { return m_pViewPort; }
};
