/*
	ZDimensionTextureBase.hpp
	Author: James Russell <jcrussell@762studios.com>
	Created: 7/1/2012

	Purpose: 

	Base implementation of a dimension (1D, 2D, 3D) texture.

	License:

	TODO

*/

#pragma once

#ifndef _ZDIMENSIONTEXTUREBASE_HPP
#define _ZDIMENSIONTEXTUREBASE_HPP

#include <ZRenderer/ZDimensionTexture.hpp>

class ZDimensionTextureBase : public ZDimensionTexture
{
protected:
	//Type of texture
	ZTextureType Type;

	//Format of texture
	ZTextureFormat Format;

	//Usage type of texture
	ZTextureUsage Usage;

	//Bitmap format (including memory buffer, if needed)
	ZBitmap Bitmap;

	//Flag indicating this is a mipmapped texture
	bool bIsMipmapped;

	//Flag indicating the texture data has been modified
	bool bIsDirty;

	//Gets the texture data from graphics memory
	virtual void GetDeviceData(void* _buffer) = 0;

	/*
	Parameterized Constructor.

	@param _type - the texture type
	@param _format - the texture internal storage format
	@param _usage - the texture usage hint
	@param _bitmap - the bitmap for this texture (or side of texture, in case of cube map)
	@param _generateMipmaps - flag indicating we should generate mipmaps for this texture
	*/
	ZDimensionTextureBase(ZTextureType _type, ZTextureFormat _format, ZTextureUsage _usage, const ZBitmap& _bitmap, bool _generateMipmaps);

public:
	//Virtual Destructor
	virtual ~ZDimensionTextureBase();

	/*
	public ZDimensionTextureBase::GetBitmapResetDirty

	Gets the bitmap data for this dimension texture.  This will return
	NULL if the texture has not been modified since the last call to
	this function, and in the case it has been modified, a call to this 
	resets the 'dirty' flag for the render target.
	
	@return (ZBitmap*) - bitmap data, NULL if not dirty
	@context (all)
	*/
	ZBitmap* GetBitmapResetDirty();

	uint32_t GetWidth() { return Bitmap.GetWidth(); }
	uint32_t GetHeight() { return Bitmap.GetHeight(); }
	uint32_t GetDepth() { return Bitmap.GetDepth(); }

	/*****************************/
	/* ZDimensionTexture Methods */
	/*****************************/

	//Subclass Implementation
	virtual bool Fill(const void* _data);

	//Subclass Implementation
	virtual const ZBitmapFormat GetBitmapFormat();

	//Subclass Implementation
	virtual void* Map(bool _discard);

	//Subclass Implementation
	virtual void Unmap();

	/********************/
	/* ZTexture Methods */
	/********************/

	//Subclass Implementation
	virtual ZTextureType GetType();

	//Subclass Implementation
	virtual ZTextureUsage GetUsage();

	//Subclass Implementation
	virtual bool IsMipmapped();
};

#endif
 
