Dengine/src/Shader.cpp

41 lines
732 B
C++
Raw Normal View History

2016-06-03 05:07:40 +00:00
#include <Dengine\Shader.h>
#include <fstream>
#include <iostream>
namespace Dengine
{
Shader::Shader()
: mProgram(0)
2016-06-03 05:07:40 +00:00
{
}
Shader::~Shader() {}
2016-06-03 05:07:40 +00:00
i32 Shader::loadProgram(GLuint vertexShader, GLuint fragmentShader)
2016-06-03 05:07:40 +00:00
{
mProgram = glCreateProgram();
glAttachShader(mProgram, vertexShader);
glAttachShader(mProgram, fragmentShader);
glLinkProgram(mProgram);
glDeleteShader(fragmentShader);
glDeleteShader(vertexShader);
2016-06-03 05:07:40 +00:00
GLint success;
GLchar infoLog[512];
glGetProgramiv(mProgram, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(mProgram, 512, NULL, infoLog);
std::cout << "glLinkProgram failed: " << infoLog << std::endl;
return -1;
2016-06-03 05:07:40 +00:00
}
return 0;
2016-06-03 05:07:40 +00:00
}
2016-06-03 05:07:40 +00:00
void Shader::use() { glUseProgram(mProgram); }
}