MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / copy_glsl

Function copy_glsl

src/shader_build.rs:673–688  ·  view source on GitHub ↗

Copies a `.glsl` or `.frag` file to the output directory, adding the generated header.

(source: &Path, rel_path: &Path, output_dir: &Path)

Source from the content-addressed store, hash-verified

671
672/// Copies a `.glsl` or `.frag` file to the output directory, adding the generated header.
673fn copy_glsl(source: &Path, rel_path: &Path, output_dir: &Path) {
674 let stem = rel_path.file_stem().unwrap().to_string_lossy();
675 let output_path = output_dir.join(format!("{}.frag.glsl", stem));
676
677 let content = std::fs::read_to_string(source)
678 .unwrap_or_else(|e| panic!("Failed to read '{}': {}", source.display(), e));
679
680 let header = format!(
681 "{}\n//! Source: {}\n",
682 GENERATED_HEADER_PREFIX,
683 rel_path.display()
684 );
685
686 std::fs::write(&output_path, format!("{}{}", header, content))
687 .unwrap_or_else(|e| panic!("Failed to write '{}': {}", output_path.display(), e));
688}
689
690/// Prepends the generated file header to an existing compiled shader.
691#[cfg(feature = "shader-build")]

Callers 1

buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected