build and use shader program

This commit is contained in:
Christoph J. Scherr 2023-10-21 19:26:45 +02:00
parent fd7f680592
commit 3c36684f41
2 changed files with 22 additions and 2 deletions

View File

@ -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.

View File

@ -17,6 +17,7 @@ protected:
unsigned int vertex;
unsigned int frag;
Base base;
unsigned int program;
};
int mainWindow(ShaderProgram* shaderProgramm, GLFWwindow* window);
GLFWwindow* initGl();