build and use shader program
This commit is contained in:
parent
fd7f680592
commit
3c36684f41
|
@ -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