From bc644127f79494e6b978afde2d5a607f57d63a0a Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Thu, 27 Feb 2014 17:39:00 +0000 Subject: [PATCH] Print line numbers with shader source. Change-Id: I9729b9bf75d5082e0a3be5a5a194e4afe0ede8c6 Signed-off-by: Francisco Santos --- dali/internal/render/shaders/program.cpp | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 6956d7e..a5633f6 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -17,6 +17,10 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include +#include + // INTERNAL INCLUDES #include #include @@ -24,6 +28,37 @@ #include #include +namespace +{ +void LogWithLineNumbers( const char * source ) +{ + unsigned int lineNumber = 0u; + const char *prev = source; + const char *ptr = prev; + + while( true ) + { + if(lineNumber > 200u) + { + break; + } + // seek the next end of line or end of text + while( *ptr!='\n' && *ptr != '\0' ) ++ptr; + + std::string line( prev, ptr-prev ); + Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%4d %s\n", lineNumber, line.c_str()); + + if( *ptr == '\0' ) + { + break; + } + prev = ++ptr; + ++lineNumber; + } +} + +} //namespace + namespace Dali { @@ -546,7 +581,9 @@ bool Program::CompileShader( GLenum shaderType, GLuint& shaderId, const char* sr if (compiled == GL_FALSE) { - DALI_LOG_ERROR("Failed to compiler shader \n%s\n", src); + DALI_LOG_ERROR("Failed to compile shader\n"); + LogWithLineNumbers(src); + std::vector< char > szLog; GLint nLength; mGlAbstraction.GetShaderiv( shaderId, GL_INFO_LOG_LENGTH, &nLength); -- 2.7.4