mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
shader: warn if GLSL shader does not contain #version line
Shaders without #version line (which are supposed to indicate GLSL 1.10) will be interpreted differently by different drivers, so this is almost certainly a mistake. In the future, we can forbid this altogether or insert #version 110 automatically.
This commit is contained in:
parent
73452957ee
commit
65a86d1b3f
@ -2750,6 +2750,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
|
||||
int ext_google_include = 0; // 1 = warn, 2 = enable
|
||||
int ext_google_line = 0;
|
||||
bool had_include = false;
|
||||
bool had_version = false;
|
||||
int lineno = 0;
|
||||
bool write_line_directive = (fileno != 0);
|
||||
|
||||
@ -2920,6 +2921,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
|
||||
write_line_directive = true;
|
||||
}
|
||||
|
||||
} else if (strcmp(directive, "version") == 0) {
|
||||
had_version = true;
|
||||
|
||||
} else if (strcmp(directive, "extension") == 0) {
|
||||
// Check for special preprocessing extensions.
|
||||
char extension[256];
|
||||
@ -3047,6 +3051,11 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
|
||||
out << line << "\n";
|
||||
}
|
||||
|
||||
if (fileno == 0 && !had_version) {
|
||||
shader_cat.warning()
|
||||
<< "GLSL shader " << fn << " does not contain a #version line!\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user