/*
 ZOpenGLTextureRenderTarget.h
 Author: Chris Ertel (cre1)

 Purpose: TODO

 Changelog
 2011/05/22 - creation (cre1)
*/

#pragma once

#ifndef _ZOPENGLTEXTURERENDERTARGET_H
#define _ZOPENGLTEXTURERENDERTARGET_H

#include <ZRendering/ZTextureRenderTarget.h>
#include <ZRendering/ZOpenGLRenderer.h>
#include <GLee/GLee.h>

class ZOpenGLTexture;
class ZOpenGLTextureRenderTarget;

class ZOpenGLTextureRenderTargetLoadRequest : public ZThreadRequest
{
private:
	ZOpenGLTextureRenderTarget *Target;

public:
	ZOpenGLTextureRenderTargetLoadRequest(ZOpenGLTextureRenderTarget *_target);

	void Execute(ZThread *_renderer);
};

class ZOpenGLTextureRenderTarget : public ZTextureRenderTarget
{
friend class ZOpenGLTextureRenderTargetLoadRequest;
protected:
	//The OpenGL Texture
//	ZOpenGLTexture Tex;

	//The glhandle to the FrameBuffer
	GLuint FrameBufferHandle;

	//The glhandle to the RenderBuffer
	GLuint RenderBufferHandle;
	float ClearColor[4];

	int Width;
	int Height;
	int BPP;

public:
	//Default Constructor
	ZOpenGLTextureRenderTarget(ZOpenGLRenderer *_renderer, int _width, int _height, int _bpp, int _rgbaSize, float *_clearColor = NULL);

	//Subclass Implementation
	bool Activate();

	//Subclass Implementation
	void Deactivate();

	void SetClearColor(float r, float g, float b, float a);

	void SetClearColor(float* _in);

	//Subclass Implementation (Currently Non-Functional)
	void SetDimensions(int _width, int _height)
	{
		URFP(_width);
		URFP(_height);
	}

	//Subclass Implementation (Currently Non-Functional)
	void SetBitsPerPixel(int _bbp)
	{
		URFP(_bbp);
	}

	//Subclass Implementation (Currently Non-Functional)
	void SetRGBASize(int _rgbaSize)
	{
		URFP(_rgbaSize);
	}

	//Gets the render target as a texture
	ZTexture* GetTexture();

	//Gets the texture as a render target
	ZRenderTarget* GetRenderTarget();
};

#endif
