From: Francisco Santos Date: Thu, 27 Feb 2014 17:39:00 +0000 (+0000) Subject: Print line numbers with shader source. X-Git-Tag: dali-2014-wk16-release~36^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F17769%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git Print line numbers with shader source. Change-Id: I9729b9bf75d5082e0a3be5a5a194e4afe0ede8c6 Signed-off-by: Francisco Santos --- 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);