Always output the shader info log if it's not empty.

This commit is contained in:
Dr. Chat 2015-12-22 14:41:18 -06:00
parent 30eda6909f
commit 59bee898f7
1 changed files with 11 additions and 8 deletions

View File

@ -135,18 +135,21 @@ bool GL4Shader::CompileProgram() {
return false; return false;
} }
// Output info log.
// log_length includes the null character.
GLint log_length = 0;
glGetProgramiv(program_, GL_INFO_LOG_LENGTH, &log_length);
std::string info_log;
info_log.resize(log_length - 1);
glGetProgramInfoLog(program_, log_length, &log_length, &info_log[0]);
if (!info_log.empty()) {
XELOGD("Shader log: %s", info_log.c_str());
}
// Get error log, if we failed to link. // Get error log, if we failed to link.
GLint link_status = 0; GLint link_status = 0;
glGetProgramiv(program_, GL_LINK_STATUS, &link_status); glGetProgramiv(program_, GL_LINK_STATUS, &link_status);
if (!link_status) { if (!link_status) {
// log_length includes the null character.
GLint log_length = 0;
glGetProgramiv(program_, GL_INFO_LOG_LENGTH, &log_length);
std::string info_log;
info_log.resize(log_length - 1);
glGetProgramInfoLog(program_, log_length, &log_length,
const_cast<char*>(info_log.data()));
XELOGE("Unable to link program: %s", info_log.c_str());
host_error_log_ = std::move(info_log); host_error_log_ = std::move(info_log);
assert_always("Unable to link generated shader"); assert_always("Unable to link generated shader");
return false; return false;