Examples¶
The repository includes CrossGL examples under examples/ and generated
reference outputs under examples/output/.
Translate from Python¶
import crosstl
metal = crosstl.translate(
"examples/graphics/SimpleShader.cgl",
backend="metal",
save_shader="SimpleShader.metal",
)
Translate from the command line¶
python -m crosstl._crosstl examples/graphics/SimpleShader.cgl --backend directx
Translate native shader input¶
Native source inputs are selected by file extension. When a reverse generator exists, the translator can import the native shader and emit CrossGL or another target.
import crosstl
crossgl = crosstl.translate("shader.hlsl", backend="cgl")
metal = crosstl.translate("shader.hlsl", backend="metal")
Useful example files¶
Category |
Path |
What it covers |
|---|---|---|
Graphics |
|
Basic vertex/fragment translation |
Graphics |
|
Larger shader structure and helper functions |
Compute |
|
Compute-stage resource and dispatch patterns |
GPU computing |
|
Parallel compute workload |
Cross-platform |
|
Portable physically based rendering shader |
Advanced language features |
|
Pattern matching and generic language constructs |