/*********************************************************************
*                                                                    *          
*                              FLY                                   *
*                           --E#Y#E--				     *
*                         ===MUSCLE===                               *
*                                                                    *
*********************************************************************/
#ifndef UNIFORM_H_
#define UNIFORM_H_

/* C++ Header Files */
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <cassert>
#include <limits>
/* OpenGL */
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glxext.h>
/* Flysimulator */
#include "../CONF/config.h"

//---------------------------------------------------------------------------

/* Standard */
using namespace std;

using std::vector;
using std::string;
using std::ifstream;
using std::map;

//---------------------------------------------------------------------------
	
/* Class Uniform */
class UNIFORM
{
private:

	GLuint location;
	
	//GLuint normalPosition;
	//GLuint colorPosition;
	//GLuint vertexPosition;
	//GLuint fudgeLocation;
	//GLuint projectionMatrix;
	//GLuint modelViewMatrix;
	
	struct shader
	{
                unsigned int id;
	        FILE *sourceFile;
	        const GLchar* filename;
	        GLchar* source;	
	        
	}vertShader, fragShader;
	
	unsigned int shaderProgram;
	
public:	
	/* Create */
	size_t ProgramSize(const GLchar* ShaderFile);
	void createShader(const GLchar* vert, const GLchar* frag);
	int compileShader(unsigned int shaderID);
	void outputLog(unsigned int shaderID);	
	int createProgram(unsigned int shaderProgram); 
	
	/* Uniform */
	void Location(unsigned int shaderProgram, unsigned int location, const char* name);
	void Uniform(unsigned int shaderProgram, const char* name, const float matrix);
	void Uniform4x4(unsigned int shaderProgram, const char* name, bool transpose, const float* matrix);
	void Uniform3x3(unsigned int shaderProgram, const char* name, bool transpose, const float* matrix);
	void sendUniform4f(unsigned int shaderProgram, const char* name, 
	                  const float red, const float green, const float blue, const float alpha);
        void sendUniform3f(unsigned int shaderProgram, const char* name, 
                          const float x, const float y, const float z);
        void sendUniform(unsigned int shaderProgram, const char* name, const float scalar); 
        
        /* Link and Bind */
        void linkProgram(unsigned int shaderProgram);
	void bindShader(unsigned int shaderProgram);
	void DeleteShader(unsigned int shaderProgram);	
};

//---------------------------------------------------------------------------

#endif

