From 2feb505b725f8e959eff95c75e42f0b9adb46a67 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 14 Jun 2012 12:30:58 +0000 Subject: [PATCH] gpu: be more verbose about shader compilation; some warnings are useful. --- src/gpu/shader.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index f368159e..6974b60f 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -210,13 +210,18 @@ Shader::Shader(char const *vert, char const *frag) glShaderSource(data->vert_id, 1, &shader, NULL); glCompileShader(data->vert_id); + glGetShaderInfoLog(data->vert_id, sizeof(errbuf), &len, errbuf); glGetShaderiv(data->vert_id, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { - glGetShaderInfoLog(data->vert_id, sizeof(errbuf), &len, errbuf); Log::Error("failed to compile vertex shader: %s", errbuf); Log::Error("shader source:\n%s\n", buf); } + else if (len > 1) + { + Log::Debug("compile log for vertex shader: %s", errbuf); + Log::Debug("shader source:\n%s\n", buf); + } #else data->vert_id = cgCreateProgram(cgCreateContext(), CG_SOURCE, vert, cgGLGetLatestProfile(CG_GL_VERTEX), @@ -249,13 +254,18 @@ Shader::Shader(char const *vert, char const *frag) glShaderSource(data->frag_id, 1, &shader, NULL); glCompileShader(data->frag_id); + glGetShaderInfoLog(data->frag_id, sizeof(errbuf), &len, errbuf); glGetShaderiv(data->frag_id, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { - glGetShaderInfoLog(data->frag_id, sizeof(errbuf), &len, errbuf); Log::Error("failed to compile fragment shader: %s", errbuf); Log::Error("shader source:\n%s\n", buf); } + else if (len > 1) + { + Log::Debug("compile log for fragment shader: %s", errbuf); + Log::Debug("shader source:\n%s\n", buf); + } #else data->frag_id = cgCreateProgram(cgCreateContext(), CG_SOURCE, frag, cgGLGetLatestProfile(CG_GL_FRAGMENT), @@ -293,6 +303,16 @@ Shader::Shader(char const *vert, char const *frag) glAttachShader(data->prog_id, data->frag_id); glLinkProgram(data->prog_id); + glGetProgramInfoLog(data->prog_id, sizeof(errbuf), &len, errbuf); + glGetProgramiv(data->prog_id, GL_LINK_STATUS, &status); + if (status != GL_TRUE) + { + Log::Error("failed to link program: %s", errbuf); + } + else if (len > 1) + { + Log::Debug("link log for program: %s", errbuf); + } glValidateProgram(data->prog_id); #endif }