/*
	ZOpenGLRenderBuffer.hpp
	Author: Chris Ertel <crertel@762studios.com>,
			James Russell <jcrussell@762studios.com>

	Purpose: 
	
	Implementation of the render buffer interface for OpenGL renderers.

	License:

	TODO
*/

#pragma once

#ifndef _ZOPENGLRENDERBUFFER_HPP
#define _ZOPENGLRENDERBUFFER_HPP

//Forward Declaration
class ZOpenGLRenderer;

#include <SST/SST_GLAPI.h>

#include <ZRenderer/ZRenderBuffer.hpp>

class ZOpenGLRenderBuffer : public ZRenderBuffer
{
protected:
	//Renderer Instance
	ZOpenGLRenderer* Renderer;

	//The type of render buffer
	ZRenderBufferType Type;

	//Width of the render buffer
	size_t Width;

	//Height of the render buffer
	size_t Height;


public:
	//Gets the GL storage type
	inline GLenum GetGLType()
	{
		switch(Type)
		{
		case ZRBT_DEPTH16:			return GL_DEPTH_COMPONENT16;
		case ZRBT_DEPTH24:			return GL_DEPTH_COMPONENT24;
		case ZRBT_DEPTH32:			return GL_DEPTH_COMPONENT32;
		case ZRBT_STENCIL8:			return GL_STENCIL_INDEX8;
		case ZRBT_DEPTH24_STENCIL8: return GL_DEPTH24_STENCIL8;
		default:					return GL_INVALID_ENUM;
		}
	}
	
	//The OpenGL handle to the render buffer
	GLuint GLHandle;

	/*
	Constructor.

	@param _renderer - the current renderer instance
	@param _type - the type of render buffer this will be
	@param _width - with of the render buffer
	@param _height - height of the render buffer
	*/
	ZOpenGLRenderBuffer( ZOpenGLRenderer *_renderer, ZRenderBufferType _type, size_t _width, size_t _height);

	//Destructor
	virtual ~ZOpenGLRenderBuffer();

	//Subclass Implementation
	virtual size_t GetHeight();

	//Subclass Implementation
	virtual ZRenderBufferType GetType();

	//Subclass Implementation
	virtual size_t GetWidth();
};

#endif