/*
	ZOpenGLShaderProgram.h
	Author: Chris Ertel <crertel@762studios.com>,
			James Russell <jcrussell@762studios.com>
	Created: 04/03/2011

	Purpose: 
	
	TODO

	License:

	TODO
*/

#pragma once

#ifndef _ZOPENGLSHADERPROGRAM_HPP
#define _ZOPENGLSHADERPROGRAM_HPP

#include <ZRenderer/ZShaderProgramBase.hpp>
#include <ZRenderer/ZOpenGLShader.hpp>

#include <SST/SST_GLAPI.h>

//Forward Declarations
class ZOpenGLRenderer;

//Struct we use to track opengl handles for uniform blocks and block members
struct ZOpenGLUniformBlockData
{
	GLuint BlockIndex;				//OpenGL Index for UniformBlocks[i]
	ZArray<GLuint> MemberIndices;	//OpenGL Index for UniformBlocks[i].Members[i]
};

//OpenGL Implementation of ZShaderProgram
class ZOpenGLShaderProgram : public ZShaderProgramBase
{
protected:
	//Parent renderer
	ZOpenGLRenderer* Renderer;

	//Static method used to link a shader program
	static void Link_(ZThread* _thread, void* _shaderProgram);

public:
	//Handle to the program in OpenGL
	GLuint GLHandle;

	//Our set of uniform indices, sampler indices, and stream indices
	ZArray<ZOpenGLUniformBlockData> OpenGLUniformBlockData;
	ZArray<GLuint>					OpenGLSamplerData;
	ZArray<GLuint>					OpenGLStreamData;

	/*
	Constructor.

	@param _renderer - the current renderer
	*/
	ZOpenGLShaderProgram(ZOpenGLRenderer* _renderer);

	//Virtual destructor
	virtual ~ZOpenGLShaderProgram();

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

#endif