Add imgui

This commit is contained in:
2020-03-21 22:38:10 +01:00
parent b22be7d6a5
commit 4a7e0ac82a
178 changed files with 73595 additions and 94 deletions

View File

@@ -9,11 +9,29 @@ OpenGlShaderProgram::OpenGlShaderProgram(std::string vertex_file, std::string ge
this->geometry_file = geometry_file;
this->fragment_file = fragment_file;
this->compiled = false;
this->setProjectionView(glm::mat4(1.0f), glm::mat4(1.0f));
}
OpenGlShaderProgram::~OpenGlShaderProgram()
{
this->unload();
}
void OpenGlShaderProgram::setProjectionView(const glm::mat4 &projection, const glm::mat4 &view)
{
this->proj = projection;
this->view = view;
this->proj_view = projection * view;
}
glm::mat4 OpenGlShaderProgram::getProjection()
{
return this->proj;
}
glm::mat4 OpenGlShaderProgram::getView()
{
return this->view;
}
std::string load_shader_program_from_file(std::string &file_name)
@@ -154,6 +172,8 @@ int OpenGlShaderProgram::use()
return -1;
glUseProgram(this->shader_program);
this->setUniformMat4("projection_view_matrix", this->proj_view);
return 0;
}
@@ -173,6 +193,14 @@ void OpenGlShaderProgram::setUniformVec2(const std::string &uniform, float *vect
}
}
void OpenGlShaderProgram::setUniformMat4(const std::string &uniform, const glm::mat4 &matrix)
{
int loc = this->getUniformLoc(uniform);
if (loc >= 0) {
glUniformMatrix4fv(loc, 1, GL_FALSE, &matrix[0][0]);
}
}
int OpenGlShaderProgram::getUniformLoc(const std::string &uniform)
{
if (!this->compiled)