mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
[glsl] Put #line after any #version lines in the chunks
The GLSL compiler requires any #version lines to be the first (real) line of the program, even #line causes an error, so if the first line of the chunk starts with #version, insert the #line directive as the second line.
This commit is contained in:
parent
00362e9f4e
commit
e263521330
1 changed files with 11 additions and 2 deletions
|
@ -129,8 +129,17 @@ GLSL_BuildShader (const char **effect_keys)
|
|||
Sys_Printf ("Unknown shader key: '%s'\n", dot);
|
||||
goto error;
|
||||
}
|
||||
if (strncmp ("#version ", chunk->text, 9) == 0) {
|
||||
const char *eol = strchr (chunk->text, '\n');
|
||||
int vline_len = eol ? eol - chunk->text + 1 : 0;
|
||||
shader->strings[num] = nva ("%.*s#line %d\n%s", vline_len,
|
||||
chunk->text,
|
||||
chunk->start_line + 1,
|
||||
chunk->text + vline_len);
|
||||
} else {
|
||||
shader->strings[num] = nva ("#line %d\n%s", chunk->start_line,
|
||||
chunk->text);
|
||||
}
|
||||
shader->src[num] = strdup (ekey->str);
|
||||
}
|
||||
dstring_delete (ekey);
|
||||
|
|
Loading…
Reference in a new issue