]> git.tdb.fi Git - libs/gl.git/commitdiff
Always print shader and program info logs in debug mode
authorMikko Rasa <tdb@tdb.fi>
Wed, 26 Oct 2016 15:16:34 +0000 (18:16 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 26 Oct 2016 15:18:42 +0000 (18:18 +0300)
They may contain useful warnings even if the code was accepted.

source/program.cpp
source/shader.cpp

index 021b23483dcdce1c074388916a38721a72aee567..82308b3405e0c42cc2086925c7633bd6b6a08770 100644 (file)
@@ -8,6 +8,7 @@
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/ext_gpu_shader4.h>
 #include <msp/gl/extensions/nv_non_square_matrices.h>
+#include <msp/io/print.h>
 #include <msp/strings/format.h>
 #include "buffer.h"
 #include "error.h"
@@ -115,6 +116,12 @@ void Program::link()
        if(!linked)
                throw compile_error(get_info_log());
 
+#ifdef DEBUG
+       std::string info_log = get_info_log();
+       if(!info_log.empty())
+               IO::print("Program link info log:\n%s", info_log);
+#endif
+
        unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS);
        vector<UniformInfo *> uniforms_by_index(count);
        for(unsigned i=0; i<count; ++i)
index 17bf3fad3196ad08b735669bda32f72bf2212a92..b620641e5af789bc2c3cc5fe87edcc1799f61249 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/gl/extensions/arb_shader_objects.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/ext_geometry_shader4.h>
+#include <msp/io/print.h>
 #include "error.h"
 #include "misc.h"
 #include "shader.h"
@@ -64,6 +65,12 @@ void Shader::compile()
        compiled = get_shader_i(id, GL_COMPILE_STATUS);
        if(!compiled)
                throw compile_error(get_info_log());
+
+#ifdef DEBUG
+       string info_log = get_info_log();
+       if(!info_log.empty())
+               IO::print("Shader compile info log:\n%s", info_log);
+#endif
 }
 
 string Shader::get_info_log() const