Skip to content

Commit 4cd8f22

Browse files
committed
test: add glsl patcher test case
1 parent 5650c5b commit 4cd8f22

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

crates/jsbindings/webgl.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,38 @@ in vec3 position;
200200
void main() {
201201
gl_Position = modelMatrix * viewMatrices[gl_ViewID_OVR] * vec4(position, 1.);
202202
}
203+
"#
204+
)
205+
}
206+
207+
#[test]
208+
#[ignore]
209+
fn test_patch_glsl_source_elif_expand() {
210+
let source_str = r#"
211+
#version 300 es
212+
#define CS1
213+
#define CS2
214+
#define CS3
215+
216+
vec3 test() {
217+
#if defined(CS1)
218+
return vec3(1.0, 0.0, 0.0);
219+
#elif defined(CS2)
220+
return vec3(2.0, 0.0, 0.0);
221+
#elif defined(CS3)
222+
return vec3(3.0, 1.0, 0.0);
223+
#else
224+
return vec3(0.0, 0.0, 1.0);
225+
#endif
226+
}
227+
"#;
228+
let patched_source_str = patch_glsl_source_from_str(source_str);
229+
assert_eq!(
230+
patched_source_str,
231+
r#"#version 300 es
232+
vec3 test() {
233+
return vec3(1., 0., 0.);
234+
}
203235
"#
204236
)
205237
}

0 commit comments

Comments
 (0)