glslt
glslt is the main library that supports the GLSL Template compiler transforms. If you are
building a system that relies on transforming GLSLT code, you'll want to interact with this
library directly instead of the command-line interface provided by glsltc.
Usage
Rust crate
The glslt crate manipulates syntax trees generated by the glsl-lang crate.
use glslt::glsl_lang::{ast::*, parse::IntoParseBuilderExt};
use glslt::transform::{Unit, TransformUnit};
let glsl_src = r#"
float sdf3d(in vec3 p);
float colort();
float sdSphere(vec3 p, float r) {
return length(p) - r;
}
float opElongate(in sdf3d primitive, in colort C, in vec3 p, in colort D, in vec3 h) {
vec3 q = p - clamp(p, -h, h);
return C() * primitive(q) * D();
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
float sz = 5.;
fragColor = vec4(vec3(opElongate(sdSphere(_p, sz), 1.0, vec3(fragCoord, 0.), 2.0, vec3(1., 2., 3.))), 1.0);
}
"#;
// Parse the GLSLT source code
let tu: TranslationUnit = glsl_src
.builder()
.context(&glslt::parse::make_parse_context(None))
.parse()
.expect("failed to parse GLSLT source")
.0;
// Create the transform unit
let mut unit = Unit::new();
// Parse declarations
for decl in tu.0.into_iter() {
unit.parse_external_declaration(decl).expect("failed to parse declaration");
}
// Generate the result
let tu = unit.into_translation_unit().expect("failed to generate output");
// Transpile the syntax tree to GLSL source
let mut output_src = String::new();
glsl_lang::transpiler::glsl::show_translation_unit(
&mut output_src,
&tu,
glsl_lang::transpiler::glsl::FormattingState::default(),
).expect("failed to generate GLSL");
Python library
If you installed the glslt library via pip install glslt or maturin develop, you may use the Python interface to the GLSLT compiler.
import glslt
# Parse the `sdf.glsl` file with `my-glsl-lib/include` being a system include
# directory for #include resolution
translation_unit = glslt.parse_files(["sdf.glsl"], ["my-glsl-lib/include"])
# Create a new minimizing transform unit
unit = glslt.MinUnit()
# Add the parsed declarations to the transform unit
unit.add_unit(translation_unit)
# Get the output of the transform
result = unit.to_translation_unit(["mainImage"])
# Print the GLSL code
print(result.to_glsl())
Author
Alixinne alixinne@pm.me
Metadata
Release files for glslt 0.7.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| glslt-0.7.6.tar.gz | 26.4 kB | Without provenance | Details for glslt-0.7.6.tar.gz |
Built distributions (wheels)
Total release size: 16.2 MB
Release files / glslt-0.7.6.tar.gz
| Download URL | glslt-0.7.6.tar.gz |
|---|---|
| Size | 26.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44deb19c2e993854acb3f4cc8c204fb1ecc2d9d68a6b1fe86d2592d2830d5c12
|
|
BLAKE2b-256 checksum How to use checksums |
683d882c481d4090bf9e52aa749b7413ff7f1a373349c7f717b5a99d4e7dfb56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp313-none-win_amd64.whl
| Download URL | glslt-0.7.6-cp313-none-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
08fd21a988eb8afa8081366981f284e5e4d7add653b4df45bd452a5e1f53c243
|
|
BLAKE2b-256 checksum How to use checksums |
a9f660eb458604f94c9010e5806a7a4e3b214efce6ac2a07b99635685000a652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | glslt-0.7.6-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 CPython 3.13 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
114308dfb4b14091daf415c655e62fa1e6252efd331b7644393d1dde042f9112
|
|
BLAKE2b-256 checksum How to use checksums |
c5dd9830c53cfc81bc1ed12c555439e2f76ff64b3c8c1a70c281dea96484d023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | glslt-0.7.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ce44e3c83e5cf8e12827cb33fc746e75d7e0fc31b812e8df3063182bc90f7b2
|
|
BLAKE2b-256 checksum How to use checksums |
e99d8acf83f61b0a960890d1ae612a870ac81fbe5f30f098a5d7230378e5179f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp312-none-win_amd64.whl
| Download URL | glslt-0.7.6-cp312-none-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8e2f7ea2db2a6fcc3ccb761f3d717aafde144f4420f07fabe67b6d3ec99b1c09
|
|
BLAKE2b-256 checksum How to use checksums |
6418c4e61efaeeeca830edada62a199ae3ad8bbb334318e71ac91aaa530a2a59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | glslt-0.7.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5612359c9acc769773e34d90a626b1255360a68c6bab731fe88f7f10e8346478
|
|
BLAKE2b-256 checksum How to use checksums |
4a5891f21e98a4dd1343b0b9c94c3152ee435566c8ad598f61cee00335de0bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp311-none-win_amd64.whl
| Download URL | glslt-0.7.6-cp311-none-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b3e25d7f7e17517d6767f92eb064247ffa72659cefa5126bf954e6318d8f534a
|
|
BLAKE2b-256 checksum How to use checksums |
7c5ef42301291703b2059745a91d7da8063f6652fce9011c5f3df33bacc54627
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | glslt-0.7.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f2ecca2176c8780200fb5b7022cd91c34baba383ba2c3a6f1283b4ec91d5edd2
|
|
BLAKE2b-256 checksum How to use checksums |
c61fd7e6ff50b9a0e21639cd40f59913ff113e82fec0763acc0684850d691e41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp310-none-win_amd64.whl
| Download URL | glslt-0.7.6-cp310-none-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
09ba3c056bb0c936772b0828c731c6cb9a8bd04c379cb9fa44d327171cf55a35
|
|
BLAKE2b-256 checksum How to use checksums |
f0a6d9afa4669e70b31a9c63d9b99508186d4fc418f7a27369a1ed686d524ea2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / glslt-0.7.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | glslt-0.7.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
1071b2dee3321268c90995d7f19f7e5815409d415d72cea50c9475332c028df2
|
|
BLAKE2b-256 checksum How to use checksums |
cc605c52d6c124e2b4179e437620dec0f9173734a6986c72ba8452352e59d1c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for glslt 0.7.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.