Browse Source

Don't query shader info log if it contains only '\0' character.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
252f489eaa
  1. 10
      src/AbstractShaderProgram.cpp
  2. 5
      src/Shader.cpp

10
src/AbstractShaderProgram.cpp

@ -116,10 +116,9 @@ std::pair<bool, std::string> AbstractShaderProgram::validate() {
/* Error or warning message. The string is returned null-terminated, scrap /* Error or warning message. The string is returned null-terminated, scrap
the \0 at the end afterwards */ the \0 at the end afterwards */
std::string message(logLength, '\n'); std::string message(logLength, '\n');
if(!message.empty()) { if(message.size() > 1)
glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]); glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(logLength-1); message.resize(std::max(logLength, 1)-1);
}
return {success, std::move(message)}; return {success, std::move(message)};
} }
@ -159,10 +158,9 @@ bool AbstractShaderProgram::link() {
/* Error or warning message. The string is returned null-terminated, scrap /* Error or warning message. The string is returned null-terminated, scrap
the \0 at the end afterwards */ the \0 at the end afterwards */
std::string message(logLength, '\n'); std::string message(logLength, '\n');
if(!message.empty()) { if(message.size() > 1)
glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]); glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(logLength-1); message.resize(std::max(logLength, 1)-1);
}
/* Show error log and delete shader */ /* Show error log and delete shader */
if(!success) { if(!success) {

5
src/Shader.cpp

@ -168,10 +168,9 @@ bool Shader::compile() {
/* Error or warning message. The string is returned null-terminated, scrap /* Error or warning message. The string is returned null-terminated, scrap
the \0 at the end afterwards */ the \0 at the end afterwards */
std::string message(logLength, '\0'); std::string message(logLength, '\0');
if(!message.empty()) { if(message.size() > 1)
glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]); glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(logLength-1); message.resize(std::max(logLength, 1)-1);
}
/* Show error log */ /* Show error log */
if(!success) { if(!success) {

Loading…
Cancel
Save