Tech ENABLE_GL_IMGUI_SHADERS - Render imgui using shaders

(cherry picked from commit prusa3d/PrusaSlicer@d0d89a4d5b)
This commit is contained in:
enricoturri1966 2023-10-27 09:05:47 +08:00 committed by Noisyfox
parent 8dc82e7a8d
commit 15bad7fc19
6 changed files with 140 additions and 41 deletions

View file

@ -122,8 +122,7 @@ bool GLShaderProgram::init_from_texts(const std::string& name, const ShaderSourc
for (size_t i = 0; i < static_cast<size_t>(EShaderType::Count); ++i) {
const std::string& source = sources[i];
if (!source.empty())
{
if (!source.empty()) {
EShaderType type = static_cast<EShaderType>(i);
auto [result, id] = create_shader(type);
if (result)
@ -301,6 +300,17 @@ void GLShaderProgram::set_uniform(int id, const Matrix3d& value) const
set_uniform(id, (Matrix3f)value.cast<float>());
}
void GLShaderProgram::set_uniform(int id, const Matrix4f& value) const
{
if (id >= 0)
glsafe(::glUniformMatrix4fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.data())));
}
void GLShaderProgram::set_uniform(int id, const Matrix4d& value) const
{
set_uniform(id, (Matrix4f)value.cast<float>());
}
void GLShaderProgram::set_uniform(int id, const Vec3f& value) const
{
if (id >= 0)