@@ -496,10 +496,14 @@ static void AddConst( std::string& str, const std::string& name, float v1, float
496496
497497static std::string GenVersionDeclaration ( const std::vector<addedExtension_t> &addedExtensions ) {
498498 // Declare version.
499- std::string str = Str::Format ( " #version %d %s\n\n " ,
499+ std::string str = Str::Format ( " #version %d %s\n " ,
500500 glConfig.shadingLanguageVersion ,
501501 glConfig.shadingLanguageVersion >= 150 ? ( glConfig.glCoreProfile ? " core" : " compatibility" ) : " " );
502502
503+ str += " #line 1000000000\n " ;
504+
505+ str += " \n " ;
506+
503507 // Add supported GLSL extensions.
504508 for ( const auto & addedExtension : addedExtensions ) {
505509 addExtension ( str, addedExtension.available , addedExtension.minGlslVersion , addedExtension.name );
@@ -858,7 +862,10 @@ std::string GLShaderManager::GetDeformShaderName( const int index ) {
858862std::string GLShaderManager::BuildDeformShaderText ( const std::string& steps ) {
859863 std::string shaderText;
860864
861- shaderText = steps + " \n " ;
865+ shaderText = " \n " + steps + " \n " ;
866+
867+ shaderText += " #line 2000000000\n " ;
868+
862869 shaderText += GetShaderText ( " deformVertexes_vp.glsl" );
863870
864871 return shaderText;
@@ -1214,6 +1221,13 @@ std::string GLShaderManager::ProcessInserts( const std::string& shaderText ) con
12141221
12151222 while ( std::getline ( shaderTextStream, line, ' \n ' ) ) {
12161223 ++lineCount;
1224+
1225+ /* The deform vertex header is prepended to the mainText and is part
1226+ of the shaderText, so we should reset line numbering after it. */
1227+ if ( line == " #line 0" ) {
1228+ lineCount = 0 ;
1229+ }
1230+
12171231 const std::string::size_type position = line.find ( " #insert" );
12181232 if ( position == std::string::npos || line.find_first_not_of ( " \t " ) != position ) {
12191233 out += line + " \n " ;
@@ -1344,7 +1358,9 @@ void GLShaderManager::InitShader( GLShader* shader ) {
13441358 if ( shaderType.enabled ) {
13451359 Com_sprintf ( filename, sizeof ( filename ), " %s%s.glsl" , shaderType.path .c_str (), shaderType.postfix );
13461360
1347- shaderType.mainText = GetShaderText ( filename );
1361+ /* The deform vertex header is prepended to the mainText,
1362+ so we should reset line numbering after it. */
1363+ shaderType.mainText = " #line 0\n " + GetShaderText ( filename );
13481364 }
13491365 }
13501366
0 commit comments