summaryrefslogtreecommitdiff
path: root/gfx/gl/program.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-08-03 12:23:54 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-08-03 12:23:54 +0100
commit969999f9858043d2a2053f93209f878a3eb5a02a (patch)
treee9007eeb149c588a0d3a82b2a8da3f8d5aa63b6b /gfx/gl/program.cpp
parentCreating a program with no shaders is not valid (diff)
downloadilt-969999f9858043d2a2053f93209f878a3eb5a02a.tar.bz2
ilt-969999f9858043d2a2053f93209f878a3eb5a02a.tar.xz
ilt-969999f9858043d2a2053f93209f878a3eb5a02a.zip
Split CheckShaderError into shader/program versions
They're similar, but need splitting for better diagnostics
Diffstat (limited to 'gfx/gl/program.cpp')
-rw-r--r--gfx/gl/program.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/gfx/gl/program.cpp b/gfx/gl/program.cpp
index 7287fde..fdd4c6f 100644
--- a/gfx/gl/program.cpp
+++ b/gfx/gl/program.cpp
@@ -10,10 +10,10 @@ void
Program::linkAndValidate() const
{
glLinkProgram(m_program);
- Shader::CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");
+ checkProgramError(m_program, GL_LINK_STATUS, "Error linking shader program");
glValidateProgram(m_program);
- Shader::CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Invalid shader program");
+ checkProgramError(m_program, GL_VALIDATE_STATUS, "Invalid shader program");
}
void
@@ -22,6 +22,21 @@ Program::use() const
glUseProgram(m_program);
}
+void
+Program::checkProgramError(GLuint program, GLuint flag, std::string_view errorMessage) const
+{
+ GLint success = 0;
+
+ glGetProgramiv(program, flag, &success);
+
+ if (success == GL_FALSE) {
+ std::array<GLchar, 1024> error {};
+ glGetProgramInfoLog(program, error.size(), nullptr, error.data());
+
+ throw std::runtime_error {std::format("{}: '{}'", errorMessage, error.data())};
+ }
+}
+
Program::UniformLocation::UniformLocation(GLuint program, const char * name) :
location {glGetUniformLocation(program, name)}
{