From 5ef76d63a9ac2b86fecfa0ded06129641e560184 Mon Sep 17 00:00:00 2001 From: Nicolas Hake Date: Sun, 16 Aug 2015 14:20:15 +0200 Subject: [PATCH] Log the same shader code as is actually compiled For whatever reason, the shader code that was passed to the compiler was different from the code that got written to the shader log. This is a huge pain in the ass when trying to debug shader errors because the line information is completely wrong. I assume this decision was a premature optimization, so I've removed it and we'll now log the exact same code as the shader compiler sees. --- src/graphics/C4Shader.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/graphics/C4Shader.cpp b/src/graphics/C4Shader.cpp index f4b265570..792da939a 100644 --- a/src/graphics/C4Shader.cpp +++ b/src/graphics/C4Shader.cpp @@ -317,19 +317,20 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms) if (hProg) Clear(); #endif + StdStrBuf VertexShader = Build(VertexSlices, true), + FragmentShader = Build(FragmentSlices, true); + // Dump if (C4Shader::IsLogging()) { ShaderLogF("******** Vertex shader for %s:", szWhat); - ShaderLog(Build(VertexSlices, true).getData()); + ShaderLog(VertexShader.getData()); ShaderLogF("******** Fragment shader for %s:", szWhat); - ShaderLog(Build(FragmentSlices, true).getData()); + ShaderLog(FragmentShader.getData()); } #ifndef USE_CONSOLE // Attempt to create shaders - StdStrBuf VertexShader = Build(VertexSlices), - FragmentShader = Build(FragmentSlices); hVert = Create(GL_VERTEX_SHADER_ARB, FormatString("%s vertex shader", szWhat).getData(), VertexShader.getData());