Beispiel #1
0
void Shader::CompileShader()
{
    glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");
 //   glGetProgramiv(program, GL_LINK_STATUS, &success);
	//if (success == 0) 
	//{
	//	glGetProgramInfoLog(program, sizeof(error), NULL, ErrorLog);
	//	fprintf(stderr, "Error linking shader program: '%s'\n", ErrorLog);
 //       exit(1);
	//}

    glValidateProgram(m_program);
	CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Invalid shader program");
    //glGetProgramiv(program, GL_VALIDATE_STATUS, &Success);
    //if (!success) {
    //    glGetProgramInfoLog(ShaderProgram, sizeof(error), NULL, ErrorLog);
    //    fprintf(stderr, "Invalid shader program: '%s'\n", ErrorLog);
    //    exit(1);
    //}

    //glUseProgram(program);

    //gScaleLocation = glGetUniformLocation(ShaderProgram, "gScale");
    //assert(gScaleLocation != 0xFFFFFFFF);
}
Beispiel #2
0
void ShaderData::CompileShader() {
	glLinkProgram(program);
	CheckShaderError(program, GL_LINK_STATUS, true, "Error linking shader program");

	glValidateProgram(program);
	CheckShaderError(program, GL_VALIDATE_STATUS, true, "Invalid shader program");
}
Beispiel #3
0
    Shader(const std::string &fileName)
    {
        program_ = glCreateProgram();

        // Vertex shader
        shaders_[0] = CreateShader(LoadShader(fileName + ".vs"),
                                   GL_VERTEX_SHADER);

        // Fragment shader
        shaders_[1] = CreateShader(LoadShader(fileName + ".fs"),
                                   GL_FRAGMENT_SHADER);

        for (unsigned i = 0 ; i < NUM_SHADERS; ++i)
            glAttachShader(program_,shaders_[i]);

        glBindAttribLocation(program_, 0, "position");
        glBindAttribLocation(program_, 1, "texCoord");

        glLinkProgram(program_);
        CheckShaderError(program_, GL_LINK_STATUS, true, "Error: Program linking failed");

        glValidateProgram(program_);
        CheckShaderError(program_, GL_VALIDATE_STATUS, true, "Error: Program is invalid");

        uniforms_[TRANSFORM_U] = glGetUniformLocation(program_, "transform");
    }
Beispiel #4
0
void Shader::CreateShader(GLenum shaderType, const std::string& fileName)
{
	//load data from file
	std::string fileShaderData = LoadUtil::LoadShader(fileName);
	if (fileShaderData == "")
	{
		return;
	}

	const GLchar* shaderData[1];
	GLint shaderDataLength[1];
	shaderData[0] = fileShaderData.c_str();
	shaderDataLength[0] = fileShaderData.length();

	//create shader
	GLuint shader = glCreateShader(shaderType);
	if (shader == 0)
		std::cerr << "Error: Shader creation failure!" << std::endl;

	//upload shader
	glShaderSource(shader, 1, shaderData, shaderDataLength);
	glCompileShader(shader);

	m_shaderList.push_back(shader);

	//check for errors
	CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error: Shader compilation failure! : " + fileName);
}
Shader::Shader(const std::string& filename)
{
	m_shaders[0] = CreateShader("./Res/Shaders/" + filename + ".vs", GL_VERTEX_SHADER); //Creates shader ID
	m_shaders[1] = CreateShader("./Res/Shaders/" + filename + ".fs", GL_FRAGMENT_SHADER);

	m_program = glCreateProgram();
	glAttachShader(m_program, m_shaders[0]);
	glAttachShader(m_program, m_shaders[1]);

	glLinkProgram(m_program);
	CheckShaderError(m_program, true, GL_LINK_STATUS, "Error: Program linking failed.");

	glValidateProgram(m_program);
	CheckShaderError(m_program, true, GL_VALIDATE_STATUS, "Error: Program validation failed.");

	glUseProgram(m_program);
}
Shader::Shader(const std::string& fileName){
	m_program = glCreateProgram();
	m_shaders[0] = createShader(LoadShader(fileName) + ".vs", GL_VERTEX_SHADER);
	m_shaders[0] = createShader(LoadShader(fileName) + ".fs", GL_FRAGMENT_SHADER);

	for (unsigned int i = 0; i < NUM_SHADERS; i++){
		glAttachShader(m_program, m_shaders[i]);
	}

	glBindAttribLocation(m_program, 0, "position");

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error: Program linking failure: ");

	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Error: Program linking failure: ");
}
Beispiel #7
0
Shader::Shader(const std::string& fileName)
{
	m_program = glCreateProgram();
	m_shaders[0] = CreateShader(LoadShader(fileName + ".vs"), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileName + ".fs"), GL_FRAGMENT_SHADER);

	for(unsigned int i = 0; i < NUM_SHADERS; i++)
		glAttachShader(m_program, m_shaders[i]);

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");

	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");

	m_uniforms[0] = glGetUniformLocation(m_program, "MVP");
	m_uniforms[1] = glGetUniformLocation(m_program, "Normal");
	m_uniforms[2] = glGetUniformLocation(m_program, "lightDirection");
}
Beispiel #8
0
Shader::Shader(const std::string& fileName)
{
	m_program = glCreateProgram();
	m_shaders[0] = CreateShader(LoadShader(fileName + ".vsh"), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileName + ".fsh"), GL_FRAGMENT_SHADER);

	for (unsigned int i = 0; i < NUM_SHADERS; i++)
		glAttachShader(m_program, m_shaders[i]);

	glBindAttribLocation(m_program, 0, "position");
	glBindAttribLocation(m_program, 1, "texCoord");

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");

	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");

	m_uniforms[TRANSFORM_U] = glGetUniformLocation(m_program, "transform");
}
void GLComputeShader::loadShader(const std::string & fileName)
{
	m_program = glCreateProgram();

	GLuint m_shader = CreateShader(LoadShader(fileName + ".compute.glsl"), GL_COMPUTE_SHADER);

	glAttachShader(m_program, m_shader);

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true);
}
void Shader::init(const std::string& fileName){
	m_program = glCreateProgram();
	m_shaders[0] = CreateShader(LoadShader(fileName + ".vs"), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileName + ".fs"), GL_FRAGMENT_SHADER);

	for(unsigned int i = 0; i < NUM_SHADERS; i++)
		glAttachShader(m_program, m_shaders[i]);

    //this maps the variavles in the vertex shader to the
    //data in functions out
	glBindAttribLocation(m_program, 0, "position");

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");

	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");
 
	m_uniforms[TRANSFORM_U] = glGetUniformLocation(m_program, "transform");
	m_uniforms[COLOR_U] = glGetUniformLocation(m_program, "color");
}//end func
Beispiel #11
0
unsigned int Renderer::CreateShaderProgram(unsigned int* shaders, int numShaders)
{
    unsigned int program = glCreateProgram();
    
    for(int i = 0; i < numShaders; i++)
        glAttachShader(program, shaders[i]);
    
    glLinkProgram(program);
    CheckShaderError(program, GL_LINK_STATUS, true, "Error linking shader program");
    
    return program;
}
Beispiel #12
0
GLuint Shader::CreateShader(const std::string& text, unsigned int type)
{
	GLuint shader = glCreateShader(type);
	if (shader == 0)
		std::cerr << "Error compiling shader type " << type << std::endl;
	const GLchar* p[1];
	p[0] = text.c_str();
	GLint lengths[1];
	lengths[0] = text.length();
	glShaderSource(shader, 1, p, lengths);
	glCompileShader(shader);
	CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error compiling shader!");
	return shader;
}
Beispiel #13
0
void Shader::CreateProgram()
{
	//create program and apply shaders
	m_program = glCreateProgram();
	for each (GLuint shader in m_shaderList)
		glAttachShader(m_program, shader);

	glBindAttribLocation(m_program, 0, "position");
	glBindAttribLocation(m_program, 1, "texCoord");
	glBindAttribLocation(m_program, 2, "normal");

	//link,validate and check for errors
	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error: Program linking failure");
	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Error: Program validation failure");

	//delete shaders
	for each(GLuint shader in m_shaderList)
	{
		glDetachShader(m_program, shader);
		glDeleteShader(shader);
	}
Shader::Shader(std::string filePath)
{
	//---------------------------------------------------------------------------
	//CREATE PROGRAM AND ADD SHADERS
	//---------------------------------------------------------------------------
	shaderProgram = glCreateProgram();
	vertexShader = createShader(loadShader("./res/shaders/" + filePath + "/vertex.vsh"), GL_VERTEX_SHADER);
	fragmentShader = createShader(loadShader("./res/shaders/" + filePath + "/fragment.fsh"), GL_FRAGMENT_SHADER);
	glAttachShader(shaderProgram, vertexShader);
	glAttachShader(shaderProgram, fragmentShader);

	//---------------------------------------------------------------------------
	//ATTRIBUTES
	//---------------------------------------------------------------------------
	glBindAttribLocation(shaderProgram, 0, "position");
	glBindAttribLocation(shaderProgram, 1, "rgbColor");
	glBindAttribLocation(shaderProgram, 2, "texCoords");
	
	//---------------------------------------------------------------------------
	//LINK PROGRAM
	//---------------------------------------------------------------------------
	glLinkProgram(shaderProgram);
	CheckShaderError(shaderProgram, GL_LINK_STATUS, true, "Error: Program linking failed: ");
	glValidateProgram(shaderProgram);
	CheckShaderError(shaderProgram, GL_VALIDATE_STATUS, true, "Error: Program is invalid: ");

	//---------------------------------------------------------------------------
	//UNIFORMS
	//---------------------------------------------------------------------------
	//transform
	uniforms[TRANSFORM] = glGetUniformLocation(shaderProgram, "transform");

	//color
	uniforms[OVERRIDE_COLOR] = glGetUniformLocation(shaderProgram, "overrideColor");
	glUniform3f(uniforms[OVERRIDE_COLOR], 1.0f, 1.0f, 1.0f);
}
Beispiel #15
0
Shader::Shader(const char* fileNameVs, const char* fileNameFs)
{
	m_program = glCreateProgram();
	m_shaders[0] = CreateShader(LoadShader(fileNameVs), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileNameFs), GL_FRAGMENT_SHADER);

	for (unsigned int i = 0; i < NUM_SHADERS; i++)
		glAttachShader(m_program, m_shaders[i]);

	glBindAttribLocation(m_program, 0, "position");
	//glBindAttribLocation(m_program, 1, "texCoord");
	glBindAttribLocation(m_program, 1, "normal");
	
	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");
	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");

	m_uniforms[TRANSFORM_U] = glGetUniformLocation(m_program, "transform");

	/*m_uniforms[0] = glGetUniformLocation(m_program, "MVP");
	m_uniforms[1] = glGetUniformLocation(m_program, "Normal");
	m_uniforms[2] = glGetUniformLocation(m_program, "lightDirection");*/
}
GLuint Shader::CreateShader(const std::string& filename, GLenum shaderType)
{
	GLuint shader = glCreateShader(shaderType);

	if (!shader) {
		std::cout << "Error: Shader creation failed." << std::endl;
		return -1;
	}

	LoadShader(shader, filename);

	glCompileShader(shader); //Compiling the shader
	CheckShaderError(shader, false, GL_COMPILE_STATUS, "Error: Vertex shader compilation failed.");

	return shader;
}
static GLuint CreateShader(const std::string& source, GLenum shaderType) {
	GLuint shaderId = glCreateShader(shaderType);

	if (shaderId == 0)
		std::cerr << "Error: Shader creation failed!" << std::endl;

	// Compile Shader
	std::cout << "Compiling Shader: " << shaderType << std::endl;
	char const * ShaderSourcePointer = source.c_str();
	glShaderSource(shaderId, 1, &ShaderSourcePointer, NULL);
	glCompileShader(shaderId);

	CheckShaderError(shaderId, "Shader compilation failed");

	return shaderId;
}
Beispiel #18
0
GLuint Shader::CreateShader(const std::string& text, GLenum shaderType)
{
	GLuint shader = glCreateShader(shaderType);

	if (shader == 0)
		LOG("Graphics", "Error: Error compiling shader type " + shaderType);

	const GLchar* shaderSourceStrings[1];
	shaderSourceStrings[0] = text.c_str();
	GLint shaderSourceStringLengths[1];
	shaderSourceStringLengths[0] = text.length();

	glShaderSource(shader, 1, shaderSourceStrings, shaderSourceStringLengths);
	glCompileShader(shader);

	CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error compiling shader!");

	return shader;
}
Beispiel #19
0
GLuint GLShader::CreateShader(const std::string & text, GLenum shaderType)
{
	GLuint shader = glCreateShader(shaderType);

	if (shader == 0)
	{
		OutputDebugStringA((char*)"Error: Shader creation failed!");
	}

	const char* shaderTextPtr = text.c_str();

	glShaderSource(shader, 1, &shaderTextPtr, nullptr);
	glCompileShader(shader);
	CheckShaderError(shader, GL_COMPILE_STATUS, false);




	return shader;
}
Beispiel #20
0
void Shader::CreateProgram()
{
	size_t i;
	
	for (i = 0; i < m_NumShaders; i++)
	{
		m_Shaders[i] = CompileShader(m_ShaderTypes[i]);
		if (!CheckShaderError(m_Shaders[i], shaderFileNames[i]))
			glAttachShader(m_ProgramID, m_Shaders[i]);
		
	}
	glBindAttribLocation(m_ProgramID, 0, "position");
	glBindAttribLocation(m_ProgramID, 1, "texCoord");
	glLinkProgram(m_ProgramID);
	if (CheckProgramError(m_ProgramID))
		glDeleteProgram(m_ProgramID);

	for (i = 0; i < m_NumShaders; i++)
		glDeleteShader(m_Shaders[i]); // flag each shader for deletion when the program gets deleted, avoids memory leaks.
}
static GLuint createShader(const std::string& text, GLenum shaderType)
{
	GLuint shader = glCreateShader(shaderType);

	if (shader == 0)
		std::cerr << "Error: Shader Creation failed!" << std::endl;

	const GLchar* shaderSourceStrings[1];
	GLint shaderSourceStringLengths[1];

	shaderSourceStrings[0] = text.c_str();
	shaderSourceStringLengths[0] = text.length();

	glShaderSource(shader, 1, shaderSourceStrings, shaderSourceStringLengths);
	glCompileShader(shader);

	CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error: Program compilation failed: ");

	return shader;
}
Beispiel #22
0
GLShader::GLShader(const std::string& fileName)
{
	//create program
	m_program = glCreateProgram();

	m_shaders[0] = CreateShader(LoadShader(fileName + ".vert.glsl"), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileName + ".frag.glsl"), GL_FRAGMENT_SHADER);
	m_shaders[2] = CreateShader(LoadShader(fileName + ".geom.glsl"), GL_GEOMETRY_SHADER);

	for (unsigned int i = 0; i < NUM_SHADERS; i++)
	{
		glAttachShader(m_program, m_shaders[i]);
	}

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true);

	m_uniforms[TRANSFROM_U] =	glGetUniformLocation(m_program, "TransformMatrix");
	m_uniforms[PROJVIEW_U] =	glGetUniformLocation(m_program, "ProjectionViewMatrix");
	m_uniforms[VIEWPOS_U] =		glGetUniformLocation(m_program, "ViewPos");
}
Beispiel #23
0
Shader::Shader(const std::string& fileName) {
	// Create program
	m_program = glCreateProgram();
	// Create shaders
	m_shaders[0] = CreateShader(LoadShader(fileName + ".vertexshader"), GL_VERTEX_SHADER);
	m_shaders[1] = CreateShader(LoadShader(fileName + ".fragmentshader"), GL_FRAGMENT_SHADER);

	// Link the program
	for (unsigned int i = 0; i < NUM_SHADERS; i++) {
		glAttachShader(m_program, m_shaders[i]);
	}
	glLinkProgram(m_program);

	// Check if linking worked
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error: Program linking failed");

	// Check if program is valid
	// Can only be done after vertex array object is bound
	// TODO Add the validation to the mesh (After the Vertex Array Object is bound)
	//glValidateProgram(m_program);
	//CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Error: Program is invalid");
}
Beispiel #24
0
static inline unsigned int CreateShader(const std::string& text, unsigned int type)
{
    GLuint shader = glCreateShader(type);
	//std::cout << text << std::endl;
    
    std::stringstream errorMessage;
    errorMessage << "Error compiling shader type " << type;

    if(shader == 0)
        Engine::GetDisplay()->Error(errorMessage.str());

    const GLchar* p[1];
    p[0] = text.c_str();
    GLint lengths[1];
    lengths[0] = text.length();

    glShaderSource(shader, 1, p, lengths);
    glCompileShader(shader);

    CheckShaderError(shader, GL_COMPILE_STATUS, false, errorMessage.str());
    
    return shader;
}
/**
* Creates the shader program used
*/
GLuint Shader::CreateShader(const std::string& text, GLenum type){
    GLuint shader = glCreateShader(type);

    if(shader == 0)
		std::cerr << "Error compiling shader type " << type << std::endl;

    const GLchar* shaderSourceString[1];
    shaderSourceString[0] = text.c_str();

    GLint shaderSourceLength[1];
    shaderSourceLength[0] = text.length();

    glShaderSource(shader,//the acutal shader
        1,//the number of sources
        shaderSourceString,//string cont
        shaderSourceLength);//string len
    glCompileShader(shader);

    CheckShaderError(shader, GL_COMPILE_STATUS, false,//its just a shader only
        "Error compiling shader!");

    return shader;
}//end func
Beispiel #26
0
GLuint Shader::CreateShader(const std::string& text, GLenum shaderType) {
	// Create shader
	GLuint shader = glCreateShader(shaderType);

	if ( shader == 0 ) {
		// TODO Error Handling (Shader creation failed)
		std::cerr << "Shader creation failed" << std::endl;
	}

	// Compile shader
	const GLchar* shaderSourceStrings[1];
	GLint shaderSourceStringLengths[1];
	shaderSourceStrings[0] = text.c_str();
	shaderSourceStringLengths[0] = text.length();
	glShaderSource(shader, 1, shaderSourceStrings, shaderSourceStringLengths);
	glCompileShader(shader);

	// Check if shader was compiled correctly
	CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error: Shader compilation failed");

	// return compiled shader
	return shader;
}
int init_shaders()
{
	GLchar vShaderStr[] =  
		"attribute vec3 position;								\n"
		"attribute vec2 texCoord;								\n"
		"varying vec2 texCoord0;								\n"
		"uniform mat4 MVP;										\n"
		"uniform int v_text;									\n"
		"void main()											\n"
		"{														\n"
		"	texCoord0 = texCoord;								\n"
		"	if(v_text == 0)										\n"
		"		{gl_Position = vec4(position, 1.0);}			\n"
		"	else 												\n"
		"		{gl_Position = MVP * vec4(position, 1.0);}		\n"
		"}														\n";
	
	GLchar fShaderStr[] =
		"varying vec2 texCoord0;								\n"
		"uniform sampler2D sampler;								\n"
		"uniform int f_text;									\n"
		"void main()											\n"
		"{														\n"
		"	if(f_text == 0)										\n"
		"		{gl_FragColor = vec4(texture2D(sampler,texCoord0).rgb,1.0);}\n"
		"	else 												\n"
		"		{gl_FragColor = vec4(0.9,0.9,0.9,texture2D(sampler,texCoord0).a);}			\n"
		"}														\n";

	const GLchar* vShaderPtr = vShaderStr;
	const GLchar* fShaderPtr = fShaderStr;

	memset( &m_shader, 0, sizeof(shader) );

	m_shader.m_program = glCreateProgram();

	m_shader.m_shaders[0] = glCreateShader(GL_VERTEX_SHADER);
	m_shader.m_shaders[1] = glCreateShader(GL_FRAGMENT_SHADER);
	if(m_shader.m_shaders[0] == 0)
	{
		printf("Error compiling VRETEX shader.\n");
		glDeleteShader(m_shader.m_shaders[0]);
		glDeleteShader(m_shader.m_shaders[1]);
		exit(-1);
	}
	else if(m_shader.m_shaders[1] == 0)
	{
		printf("Error compiling FRAGMENT shader.\n");
		glDeleteShader(m_shader.m_shaders[0]);
		glDeleteShader(m_shader.m_shaders[1]);
		exit(-1);
	}

	glShaderSource(m_shader.m_shaders[0], 1, &vShaderPtr, NULL);
	glCompileShader(m_shader.m_shaders[0]);
	CheckShaderError(m_shader.m_shaders[0], GL_COMPILE_STATUS, false);

	glShaderSource(m_shader.m_shaders[1], 1, &fShaderPtr, NULL);
	glCompileShader(m_shader.m_shaders[1]);
	CheckShaderError(m_shader.m_shaders[1], GL_COMPILE_STATUS, false);

	glAttachShader (m_shader.m_program, m_shader.m_shaders[0]);
	glAttachShader (m_shader.m_program, m_shader.m_shaders[1]);

	glLinkProgram(m_shader.m_program);
	CheckShaderError(m_shader.m_program, GL_LINK_STATUS, true);

	glValidateProgram(m_shader.m_program);
	CheckShaderError(m_shader.m_program, GL_LINK_STATUS, true);

	glUseProgram(m_shader.m_program);

	return (0);
}
Beispiel #28
0
void Renderer::ValidateShaderProgram(unsigned int program)
{
    glValidateProgram(program);
    CheckShaderError(program, GL_VALIDATE_STATUS, true, "Invalid shader program");
}
Beispiel #29
0
Shader::Shader(const std::string& fileNameVS, const std::string& fileNameFS):
m_fogEnabled(true)
{
	m_program = glCreateProgram();
	
	m_lightPosition = glm::vec3(0, 100, 100);
	m_lightDirection = glm::vec3(0, 0, 0);

	m_shaders[0] = CreateShader(
		Loader::LoadFileContent(fileNameVS),
		GL_VERTEX_SHADER
	);
	
	m_shaders[1] = CreateShader(
		Loader::LoadFileContent(fileNameFS),
		GL_FRAGMENT_SHADER
	);

	for (unsigned int i = 0; i < NUM_SHADERS; i++)
		glAttachShader(m_program, m_shaders[i]);

	glBindAttribLocation(m_program, 0, "position");
	glBindAttribLocation(m_program, 1, "texCoord");
	glBindAttribLocation(m_program, 2, "normal");

	glLinkProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");

	glValidateProgram(m_program);
	CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");

	// MVP
	m_uniforms[UNIFORM_MODEL_MATRIX_LOCATION] = glGetUniformLocation(m_program, "modelMat");
	m_uniforms[UNIFORM_VIEW_MATRIX_LOCATION] = glGetUniformLocation(m_program, "viewMat");
	m_uniforms[UNIFORM_PROJ_MATRIX_LOCATION] = glGetUniformLocation(m_program, "projectionMat");

	// NORMAL
	m_uniforms[UNIFORM_NORMAL_LOCATION] = glGetUniformLocation(m_program, "normalMat");

	// LIGHT
	m_uniforms[UNIFORM_LIGHT_POSITION_LOCATION] = glGetUniformLocation(m_program, "light.position");
	m_uniforms[UNIFORM_LIGHT_DIRECTION_LOCATION] = glGetUniformLocation(m_program, "light.direction");
	m_uniforms[UNIFORM_LIGHT_ATTENTUATION_LOCATION] = glGetUniformLocation(m_program, "light.attentuation");
	m_uniforms[UNIFORM_LIGHT_COLOR_LOCATION] = glGetUniformLocation(m_program, "light.color");

	// FOG
	m_uniforms[UNIFORM_FOG_ENABLED] = glGetUniformLocation(m_program, "enableFog");
	
	// MATERIAL
	m_uniforms[UNIFORM_MAT_DIFFUSE_LOCATION] = glGetUniformLocation(m_program, "meshMat.diffuse");
	m_uniforms[UNIFORM_MAT_AMBIENT_LOCATION] = glGetUniformLocation(m_program, "meshMat.ambient");
	m_uniforms[UNIFORM_MAT_SPECULAR_LOCATION] = glGetUniformLocation(m_program, "meshMat.specular");
	m_uniforms[UNIFORM_MAT_EMISSIVE_LOCATION] = glGetUniformLocation(m_program, "meshMat.emissive");
	m_uniforms[UNIFORM_MAT_SHINE_LOCATION] = glGetUniformLocation(m_program, "meshMat.shininess");

	// TEXTURE SAMPLER
	m_uniforms[UNIFORM_TEX_SAMPLER_0] = glGetUniformLocation(m_program, "texSampler0");
	m_uniforms[UNIFORM_TEX_SAMPLER_1] = glGetUniformLocation(m_program, "texSampler1");
	m_uniforms[UNIFORM_TEX_SAMPLER_2] = glGetUniformLocation(m_program, "texSampler2");
	m_uniforms[UNIFORM_TEX_SAMPLER_3] = glGetUniformLocation(m_program, "texSampler3");

	// TIME
	m_uniforms[UNIFORM_TIME_LOCATION] = glGetUniformLocation(m_program, "time");

}