cyborg/examples/shader_includes.rs

20 lines
591 B
Rust

use cyborg::shader::{parse_wgsl, generate_wgsl, add_includes};
use cyborg::logger::Timer;
fn main() {
let comp_timer = Timer::start("Shader compilation");
// Generate a shader and preprocess it
let mut source = std::fs::read_to_string("src/shader.wgsl").unwrap();
source = add_includes(&source);
// Parse the WGSL into a usable module
let module = parse_wgsl(&source);
// Generate a valid WGSL string from the module
let gen_wgsl = generate_wgsl(&module);
println!("Generated WGSL:\n\n{}", gen_wgsl);
comp_timer.print_status();
}