diff --git a/src/graphics.cpp b/src/graphics.cpp index e4e6912..ff1c321 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -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. diff --git a/src/graphics.hpp b/src/graphics.hpp index 6bf195d..9b93039 100644 --- a/src/graphics.hpp +++ b/src/graphics.hpp @@ -17,6 +17,7 @@ protected: unsigned int vertex; unsigned int frag; Base base; + unsigned int program; }; int mainWindow(ShaderProgram* shaderProgramm, GLFWwindow* window); GLFWwindow* initGl();