@@ -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,11 @@ std::string GLShaderManager::ProcessInserts( const std::string& shaderText ) con
12141221
12151222 while ( std::getline ( shaderTextStream, line, ' \n ' ) ) {
12161223 ++lineCount;
1224+
1225+ if ( line == " #line 0" ) {
1226+ lineCount = 0 ;
1227+ }
1228+
12171229 const std::string::size_type position = line.find ( " #insert" );
12181230 if ( position == std::string::npos || line.find_first_not_of ( " \t " ) != position ) {
12191231 out += line + " \n " ;
@@ -1344,7 +1356,7 @@ void GLShaderManager::InitShader( GLShader* shader ) {
13441356 if ( shaderType.enabled ) {
13451357 Com_sprintf ( filename, sizeof ( filename ), " %s%s.glsl" , shaderType.path .c_str (), shaderType.postfix );
13461358
1347- shaderType.mainText = GetShaderText ( filename );
1359+ shaderType.mainText = " #line 0 \n " + GetShaderText ( filename );
13481360 }
13491361 }
13501362
0 commit comments