From e9885141e4049a06b89000bf34959174fb2d4491 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 8 Jun 2018 14:15:59 +0200 Subject: Expose compute shader state --- src/shader/util.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/shader/util.cc') diff --git a/src/shader/util.cc b/src/shader/util.cc index 07a1128..be59ac1 100644 --- a/src/shader/util.cc +++ b/src/shader/util.cc @@ -7,9 +7,12 @@ namespace util { GLint getUniform(GLuint program, const std::string& name) { const GLint uniform = glGetUniformLocation(program, name.c_str()); + if ( uniform == -1 ) { std::cerr << "Could not bind uniform " << name << std::endl; + return -1; } + return uniform; } @@ -18,7 +21,7 @@ GLint compileShader(const std::string& source, GLenum type) { if ( !shader ) { std::cerr << "Cannot create a shader of type " << type << std::endl; - exit(-1); + return -1; } const char* source_data = source.c_str(); @@ -29,16 +32,22 @@ GLint compileShader(const std::string& source, GLenum type) { GLint compiled; glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if ( !compiled ) { std::cerr << "Cannot compile shader" << std::endl; + GLint maxLength = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); + std::vector errorLog(maxLength); glGetShaderInfoLog(shader, maxLength, &maxLength, &errorLog[0]); + for( auto c : errorLog ) { std::cerr << c; } std::cerr << std::endl; + + return -1; } return shader; -- cgit v1.2.3