#include "BstmDisplay.h"

namespace Brainstem
{
	Display::Display(IDirect3DDevice9* device) 
	{ 
		D3DVIEWPORT9 Viewport;
		device->GetViewport(&Viewport);

		IDirect3DSurface9* BackBuffer;

		device->GetRenderTarget(0, &BackBuffer);
		D3DSURFACE_DESC desc;
		BackBuffer->GetDesc(&desc);

		device->CreateRenderTarget(desc.Width, desc.Height, desc.Format, 
										  desc.MultiSampleType, desc.MultiSampleQuality,
										  false, &Target, NULL);

		device->CreateTexture(desc.Width, desc.Height, 1, D3DUSAGE_RENDERTARGET, desc.Format, D3DPOOL_DEFAULT, &Texture, NULL);

		Background = Color(0.39f, 0.58f, 0.92f, 1.0f);
		Filter = Color(1.0f, 1.0f, 1.0f, 1.0f);
		Scale = Vector3<float>(1.0f,1.0f, 1.0f);

		RenderMode = RENDER_SOLID;
		SAFE_RELEASE(BackBuffer);
	}
	Display::~Display() { }

	void Display::AddEffect(const char* name)
	{
		Effects.push_back(name);
	}

	void Display::Release()
	{
		WRITE_RELEASE(this);

		SAFE_RELEASE(Texture);
		SAFE_RELEASE(Target);
	}
}