mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
shader: Fix support for #pragma include <example.glsl>
in GLSL
This commit is contained in:
parent
11746457ff
commit
0220a43ce0
@ -2876,7 +2876,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
|
||||
source_dir = full_fn.get_dirname();
|
||||
incfn = incfile;
|
||||
|
||||
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %zn", incfile, &nread) == 1
|
||||
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\>]> %zn", incfile, &nread) == 1
|
||||
&& nread == line.size()) {
|
||||
// Angled includes are also OK, but we don't search in the directory
|
||||
// of the source file.
|
||||
|
10
tests/display/glsl_include_angle.vert
Normal file
10
tests/display/glsl_include_angle.vert
Normal file
@ -0,0 +1,10 @@
|
||||
#version 150
|
||||
|
||||
#pragma include <glsl_include_inputs.glsl>
|
||||
|
||||
// Vertex inputs
|
||||
in vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
}
|
10
tests/display/glsl_include_angle_legacy.vert
Normal file
10
tests/display/glsl_include_angle_legacy.vert
Normal file
@ -0,0 +1,10 @@
|
||||
#version 120
|
||||
|
||||
#pragma include <glsl_include_inputs.glsl>
|
||||
|
||||
// Vertex inputs
|
||||
attribute vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
}
|
@ -497,3 +497,31 @@ def test_glsl_includes(gsg):
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_include' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
run_glsl_compile_check(gsg, vert_path, frag_path)
|
||||
|
||||
|
||||
def test_glsl_includes_angle_nodir(gsg):
|
||||
"""Test preprocessing includes with angle includes without model-path"""
|
||||
suffix = ''
|
||||
if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50):
|
||||
suffix = '_legacy'
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_include_angle' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
assert core.Shader.load(core.Shader.SL_GLSL, vert_path, frag_path) is None
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def with_current_dir_on_model_path():
|
||||
model_path = core.get_model_path()
|
||||
model_path.prepend_directory(core.Filename.from_os_specific(os.path.dirname(__file__)))
|
||||
yield
|
||||
model_path.clear_local_value()
|
||||
|
||||
|
||||
def test_glsl_includes_angle_withdir(gsg, with_current_dir_on_model_path):
|
||||
"""Test preprocessing includes with angle includes with model-path"""
|
||||
suffix = ''
|
||||
if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50):
|
||||
suffix = '_legacy'
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_include_angle' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
run_glsl_compile_check(gsg, vert_path, frag_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user