From db5e0f4e27726a1bcda64edb81db5a482768e05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 21 Oct 2016 23:27:26 +0200 Subject: [PATCH] Don't add anything before user-specified shader version directive. Thanks @acterhd for the report. --- src/Magnum/Shader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Shader.cpp b/src/Magnum/Shader.cpp index 9a4ef5a8d..eb2a0f125 100644 --- a/src/Magnum/Shader.cpp +++ b/src/Magnum/Shader.cpp @@ -784,9 +784,16 @@ Shader& Shader::addSource(std::string source) { converter << (_sources.size()+1)/2; #endif - /* Fix line numbers, so line 41 of third added file is marked as 3(41). - Source 0 is the #version string added in constructor. */ - _sources.push_back("#line 1 " + + /* Fix line numbers, so line 41 of third added file is marked as 3(41) + in case shader version was not Version::None, because then source 0 + is the #version directive added in constructur. + + If version was Version::None, line 41 of third added file is marked + as 2(41). We apparently can't add even the #line directive before + the potential `#version` directive -- in that case the first source + file is not marked with any file number, but that's equivalent to + the default where first file is marked as 0. */ + if(!_sources.empty()) _sources.push_back("#line 1 " + #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) std::to_string((_sources.size()+1)/2) + #else