build and use shader program
This commit is contained in:
parent
fd7f680592
commit
3c36684f41
|
@ -54,8 +54,8 @@ ShaderProgram::ShaderProgram(Base base, string vertexSource,
|
|||
string fragSource) {
|
||||
int success;
|
||||
char infoLog[512];
|
||||
const char* vertexSource_c = vertexSource.c_str();
|
||||
const char* fragSource_c = fragSource.c_str();
|
||||
const char *vertexSource_c = vertexSource.c_str();
|
||||
const char *fragSource_c = fragSource.c_str();
|
||||
this->base = base;
|
||||
BOOST_LOG_TRIVIAL(info) << "With base program \"" << this->baseName() << "\"";
|
||||
// NOTE: char arrays and char pointers are not actually the same.
|
||||
|
@ -90,6 +90,25 @@ ShaderProgram::ShaderProgram(Base base, string vertexSource,
|
|||
<< infoLog << std::endl;
|
||||
exit(EXIT_SHADER);
|
||||
}
|
||||
|
||||
// combine it all in a actual program
|
||||
this->program = glCreateProgram();
|
||||
glAttachShader(this->program, this->vertex);
|
||||
glAttachShader(this->program, this->frag);
|
||||
glLinkProgram(this->program);
|
||||
|
||||
glGetProgramiv(this->program, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetProgramInfoLog(this->program, 512, NULL, infoLog);
|
||||
BOOST_LOG_TRIVIAL(fatal) << "could not link shader program:\n\n"
|
||||
<< infoLog << std::endl;
|
||||
exit(EXIT_SHADER);
|
||||
}
|
||||
|
||||
// finalizing our setup
|
||||
glUseProgram(this->program);
|
||||
glDeleteShader(this->vertex);
|
||||
glDeleteShader(this->frag);
|
||||
}
|
||||
|
||||
/** defines the base program behavior.
|
||||
|
|
|
@ -17,6 +17,7 @@ protected:
|
|||
unsigned int vertex;
|
||||
unsigned int frag;
|
||||
Base base;
|
||||
unsigned int program;
|
||||
};
|
||||
int mainWindow(ShaderProgram* shaderProgramm, GLFWwindow* window);
|
||||
GLFWwindow* initGl();
|
||||
|
|
Loading…
Reference in New Issue