summaryrefslogtreecommitdiff
path: root/gfx/gl/shader.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/shader.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/shader.cpp')
-rw-r--r--gfx/gl/shader.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/gfx/gl/shader.cpp b/gfx/gl/shader.cpp
index 0bc127a..47d36d0 100644
--- a/gfx/gl/shader.cpp
+++ b/gfx/gl/shader.cpp
@@ -46,30 +46,20 @@ Shader::compile() const
}
glCompileShader(shader);
- CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error compiling shader!");
+ checkShaderError(shader, GL_COMPILE_STATUS, "Error compiling shader!");
return shader;
}
void
-Shader::CheckShaderError(GLuint shader, GLuint flag, bool isProgram, std::string_view errorMessage)
+Shader::checkShaderError(GLuint shader, GLuint flag, std::string_view errorMessage) const
{
GLint success = 0;
- if (isProgram) {
- glGetProgramiv(shader, flag, &success);
- }
- else {
- glGetShaderiv(shader, flag, &success);
- }
+ glGetShaderiv(shader, flag, &success);
if (success == GL_FALSE) {
std::array<GLchar, 1024> error {};
- if (isProgram) {
- glGetProgramInfoLog(shader, error.size(), nullptr, error.data());
- }
- else {
- glGetShaderInfoLog(shader, error.size(), nullptr, error.data());
- }
+ glGetShaderInfoLog(shader, error.size(), nullptr, error.data());
throw std::runtime_error {std::format("{}: '{}'", errorMessage, error.data())};
}