Skip to content

Commit

Permalink
Address more view comments: delete new lines in log messages, use imp…
Browse files Browse the repository at this point in the history
…licit includes (yuk), adjust error message etc.
  • Loading branch information
gmcode committed May 20, 2015
1 parent 9181401 commit 443ca16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 6 additions & 7 deletions src/engine/renderer/gl_shader.cpp
Expand Up @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// gl_shader.cpp -- GLSL shader handling

#include "gl_shader.h"
#include <type_traits>

// We currently write GLShaderHeader to a file and memcpy all over it.
// Make sure it's a pod, so we don't put a std::string in it or something
Expand Down Expand Up @@ -255,10 +254,7 @@ namespace // Implementation details

std::string GetShaderText(Str::StringRef filename)
{
Log::Debug("loading shader '%s'\n", filename);

// Shader type should be set during initialisation.

if (shaderKind == ShaderKind::BuiltIn)
{
// Look for the shader internally. If not found, look for it externally.
Expand All @@ -272,16 +268,19 @@ namespace // Implementation details
{
std::string shaderText;
std::string shaderFilename = GetShaderFilename(filename);

Log::Debug("loading shader '%s'", shaderFilename);

std::error_code openErr;

FS::File shaderFile = FS::RawPath::OpenRead(shaderFilename, openErr);
if (openErr)
ThrowShaderError(Str::Format("Cannot load shader from file: %s\n", shaderFilename));
ThrowShaderError(Str::Format("Cannot load shader from file %s: %s\n", shaderFilename, openErr.message()));

std::error_code readErr;
shaderText = shaderFile.ReadAll(readErr);
if (readErr)
ThrowShaderError(Str::Format("Failed to read shader from file: %s\n", shaderFilename));
ThrowShaderError(Str::Format("Failed to read shader from file %s: %s\n", shaderFilename, openErr.message()));

NormalizeShaderText(shaderText);
if (shaderText.empty())
Expand All @@ -298,7 +297,7 @@ namespace // Implementation details
// and he translation script needs to be run.
auto textPtr = GetInternalShader(filename);
if (textPtr != nullptr && textPtr != shaderText)
Log::Notice("Note shader file differs from built-in shader: %s\n", shaderFilename);
Log::Notice("Note shader file differs from built-in shader: %s", shaderFilename);
return shaderText;
}
// Will never reach here.
Expand Down
6 changes: 2 additions & 4 deletions src/engine/renderer/tr_shade.cpp
Expand Up @@ -165,7 +165,7 @@ void GLSL_InitGPUShaders()
}
catch (const ShaderException& e)
{
Log::Warn("External shaders failed. Error: %s", e.what());
Log::Warn("External shaders failed: %s", e.what());
Log::Warn("Attempting to use built in shaders instead.");
shaderKind = ShaderKind::BuiltIn;
}
Expand All @@ -184,9 +184,7 @@ void GLSL_InitGPUShaders()
}
catch (const ShaderException&e)
{
Log::Warn("Built-in shaders failed: %s.", e.what());

Sys::Error(e.what()); // Fatal.
Sys::Error("Built-in shaders failed: %s", e.what()); // Fatal.
};
if (wasExternal)
Log::Warn("Switched from external to built-in shaders.");
Expand Down

0 comments on commit 443ca16

Please sign in to comment.