/*
/ TEXTURE.H
/ *********
/ Handles Direct3D textures, from loading to
/ releasing.
/
/ Will Beddow 2010 - http://343gs.com/brainstem
/
/ This software is currently under development
/ and is subject to change and improvement. Some
/ aspects of the system are incomplete and/or 
/ unstable due to ongoing implementation.
/
*/

#ifndef __TEXTURE_H__
#define __TEXTURE_H__

#include "Compile.h"
#include "Types.h"

#include <d3dx9.h>

namespace Brainstem
{
	class Texture : public ITexture
	{
	public:
		Texture() { Data = NULL; }
		Texture(IDirect3DTexture9* texture) { Data = texture; }
		Texture(IDirect3DDevice9* device, const char *textureFilename) { Load(device, textureFilename); }
		~Texture() { }

		std::string ID;
		IDirect3DTexture9* Data;

		void Load(IDirect3DDevice9* device, const char *textureFilename)
		{
			IDirect3DTexture9 * newTexture = NULL;
			HRESULT hr = D3DXCreateTextureFromFile(device, textureFilename, &Data);

			if (FAILED(hr)) 
			{
				WRITE_ERROR(this, "Failed to Load Model Texture [" << textureFilename << "]");
				Data = NULL;
			}
		}

		void Release() { SAFE_RELEASE(Data); }

		AUTO_OBJECT_SIZE;
		virtual const char* GetName() { return "Texture"; }
	};
}

#endif