#ifndef TEXTURE_H
#define TEXTURE_H

#include "object.h"
#include <string>

namespace CBK
{
	template<int NumberTextureStages = 1>
	class _Texture : public Object
	{
	public:
		_Texture(const std::string& name, IDirect3DDevice9* device);
		~_Texture(void);

		_Texture& load(const std::string& name);
		_Texture& setMipMapping(const DWORD& magFilter, const DWORD& minFilter, const DWORD& mipFilter);

		void apply(const DWORD& stage);
		inline void apply(void);

		static void clear(IDirect3DDevice9* device, const DWORD& stage = 0);

		virtual Object& reset(void);

		IDirect3DTexture9* getTexture(void) const;

		static unsigned long numTextureChanges;
	protected:
		IDirect3DTexture9* texture;

		DWORD magFilter;
		DWORD minFilter;
		DWORD mipFilter;

	private:
		static _Texture* currentTexture[NumberTextureStages];
	};

	typedef _Texture<> Texture;
}

#include "texture.inl"

#endif //TEXTURE_H