Skip to main content

No project description provided

Project description

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 glsltcc.

Usage

Rust crate

The glslt crate manipulates syntax trees generated by the glsl crate (note that the fork currently used is https://github.com/vtavernier/glsl/tree/dev/).

use glslt::glsl::parser::Parse;
use glslt::glsl::syntax::*;
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 GLSL source code
let tu = TranslationUnit::parse(glsl_src).expect("failed to parse GLSLT source");

// Create the transform unit
let mut unit = Unit::new();

// Parse declarations
for decl in (tu.0).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::transpiler::glsl::show_translation_unit(
    &mut output_src,
    &tu,
    glsl::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

Vincent Tavernier vince.tavernier@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glslt-0.4.2.tar.gz (16.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

glslt-0.4.2-cp39-cp39-manylinux1_x86_64.whl (750.2 kB view details)

Uploaded CPython 3.9

glslt-0.4.2-cp39-cp39-manylinux1_i686.whl (800.1 kB view details)

Uploaded CPython 3.9

glslt-0.4.2-cp38-none-win_amd64.whl (687.4 kB view details)

Uploaded CPython 3.8Windows x86-64

glslt-0.4.2-cp38-none-win32.whl (630.3 kB view details)

Uploaded CPython 3.8Windows x86

glslt-0.4.2-cp38-cp38-manylinux1_x86_64.whl (750.2 kB view details)

Uploaded CPython 3.8

glslt-0.4.2-cp38-cp38-manylinux1_i686.whl (800.1 kB view details)

Uploaded CPython 3.8

glslt-0.4.2-cp37-none-win_amd64.whl (687.5 kB view details)

Uploaded CPython 3.7Windows x86-64

glslt-0.4.2-cp37-none-win32.whl (630.3 kB view details)

Uploaded CPython 3.7Windows x86

glslt-0.4.2-cp37-cp37m-manylinux1_x86_64.whl (750.3 kB view details)

Uploaded CPython 3.7m

glslt-0.4.2-cp37-cp37m-manylinux1_i686.whl (800.1 kB view details)

Uploaded CPython 3.7m

glslt-0.4.2-cp36-cp36m-manylinux1_x86_64.whl (750.4 kB view details)

Uploaded CPython 3.6m

glslt-0.4.2-cp36-cp36m-manylinux1_i686.whl (800.4 kB view details)

Uploaded CPython 3.6m

glslt-0.4.2-cp35-none-win_amd64.whl (687.5 kB view details)

Uploaded CPython 3.5Windows x86-64

glslt-0.4.2-cp35-none-win32.whl (630.4 kB view details)

Uploaded CPython 3.5Windows x86

glslt-0.4.2-cp35-cp35m-manylinux1_x86_64.whl (750.0 kB view details)

Uploaded CPython 3.5m

glslt-0.4.2-cp35-cp35m-manylinux1_i686.whl (799.8 kB view details)

Uploaded CPython 3.5m

File details

Details for the file glslt-0.4.2.tar.gz.

File metadata

  • Download URL: glslt-0.4.2.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ebd9211f363086dc424aa96b45d50be6b0f73d44b46d27756fcfaf3c42972da8
MD5 522c9b786f7c7e49ad2bab28c613805d
BLAKE2b-256 80f6f5ab5359060938595d016b24727817e79394bb1e7230387b26ecd5a2387e

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 750.2 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d7e622bea3d74198b2dba5fc2e18535cf20a3f51416c46c564d6abf342d0ea9
MD5 d21a2ce3ea55278f8aab70bd6ff90563
BLAKE2b-256 36edecc12252d60190359167ce4d0493110eb20695d5cb38d09393e7ebd7b9ab

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp39-cp39-manylinux1_i686.whl.

File metadata

  • Download URL: glslt-0.4.2-cp39-cp39-manylinux1_i686.whl
  • Upload date:
  • Size: 800.1 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp39-cp39-manylinux1_i686.whl
Algorithm Hash digest
SHA256 79f93e1663c668daf0e6f8d5ffe06917b5e3e6097351484a4b34ac027a378ad1
MD5 557aef9a2b1e2609c710a8b5209b8809
BLAKE2b-256 f98495c5acd9949052cc5593aa46f96594e3768c8aa94d2d260d8e8ca1f618d5

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp38-none-win_amd64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 687.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 87aa30a9a5e4971871b655b767d3ad8292d06713843689821fbae6c3db0974a0
MD5 7d747d44f86f7c96440ec25e9bc251ec
BLAKE2b-256 d346a12f87ad0f0a06a8d0fe9395ccdb8f4a351c386619f0c8a88165717265b4

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp38-none-win32.whl.

File metadata

  • Download URL: glslt-0.4.2-cp38-none-win32.whl
  • Upload date:
  • Size: 630.3 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp38-none-win32.whl
Algorithm Hash digest
SHA256 226a8f50b0b0dd88736de0ad98a5a3ea4146be939e2e2cced637cc2bbca541ba
MD5 d9420b3c61fbcba3f68058e5dc364a3e
BLAKE2b-256 257cf871c2bccb7bd95b194f08d4ec1e0eab25f0112679683c5022e6cd10536d

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 750.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 68a13255537ae450b6403c86824b95bcb03508eaf01ba58e382daca53f4d671d
MD5 b208d60362460a1c88b16b1ecb2d2719
BLAKE2b-256 25630ca4fa32401c07b5be3c90b166063f6732179f3e3d5491b4f3677dbc4009

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: glslt-0.4.2-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 800.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b7d97db418b9449aa9ee36c9294df9cc372d4d8f1fa5ad90a70efb5e7b58e676
MD5 2fd9fad9555339babdfa040511a70f4c
BLAKE2b-256 76031d3a5e912a80838f608d887dda892da90367e43584f262ed77e86d829d68

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp37-none-win_amd64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 687.5 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 766b4631603a2bdc48228548424602b60860aa82c79bed2cc603824c3cfa49e2
MD5 54e7fa7d16ca5f35d13d25bd1d2b98ee
BLAKE2b-256 c4fc4ce6818004650ced25960ddffc251566dcf7eca40e0e0edc7cae1cb6486e

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp37-none-win32.whl.

File metadata

  • Download URL: glslt-0.4.2-cp37-none-win32.whl
  • Upload date:
  • Size: 630.3 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp37-none-win32.whl
Algorithm Hash digest
SHA256 d76df85cc6d369d78adaa1e3475377ed08e044887bc0cadae8c012da389c840d
MD5 95fd5ccdd066307344bbfcafd65b2ff0
BLAKE2b-256 4afc03352f2a2ca32bd91da3ae211bc5c6bf6393cb82f619a753a537f2b8d196

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 750.3 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a641cfab515bfb149631cfa6fcd422dabbf8964384dc1147122cb6f374871c53
MD5 aea15f2c5d631a67b9f2424c619ba12a
BLAKE2b-256 5f3c9d921d850082c2399303a77d7c7e204aba0c30d8fde6017f6f16531f9e3a

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: glslt-0.4.2-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 800.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9945a8d68b3ee95fdaec8077c685393e24c6cf0d0e8347a63c7df6f9fc300ac2
MD5 9b71fcf4d0023af19075ff52dc66dd62
BLAKE2b-256 462f4bf2a70e5b54df0568b1cd6d767a298e2d040804d5512daeed53d15e1cc4

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 750.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3d656d198030b252f2d2ef9c8eaa2652dfa8932025868b041779bf104c81f183
MD5 0824087516911666c7cad7f6ea89341b
BLAKE2b-256 7d946ef0fb7b73d8415bf80b9fa40dfaaa73f2e9e7f73421381aaf3f6fa7da0e

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: glslt-0.4.2-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 800.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 368790672cb3ecbd73ca3d55d928879355d1c92f402fbbf209a3301ce5fe38de
MD5 c25c28fddc2483630f3c908831c2fa97
BLAKE2b-256 41ba2a3c4ce90d87946252a826d6f3bc572c7a70144c030d8fec1e4a9734be36

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp35-none-win_amd64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp35-none-win_amd64.whl
  • Upload date:
  • Size: 687.5 kB
  • Tags: CPython 3.5, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 061a440b43db6cd027ecec4846b4b06e44226990c73939d18a6f2f6de3694e8c
MD5 ff8d1335546b8e7b355957e7753ee87a
BLAKE2b-256 134e32fac0d827b7b2f4474fe08a04b0a7035fa8b81c8586e2185edd5bdcf029

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp35-none-win32.whl.

File metadata

  • Download URL: glslt-0.4.2-cp35-none-win32.whl
  • Upload date:
  • Size: 630.4 kB
  • Tags: CPython 3.5, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp35-none-win32.whl
Algorithm Hash digest
SHA256 6aee43c2ca75ee0a1a08bba37b719d00b8a9bc54d7b968dc5282eaf66555f035
MD5 178042c97320ca1cb171e41844e5e8c5
BLAKE2b-256 e4ecdc60b23a30f23f07b543af5c5d0888cad241cbe7b75892fe80d211c48388

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: glslt-0.4.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 750.0 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 416d0cfa5b56888954798167275201867dbc029b8881784ffdd337f4ef6ec96c
MD5 6f0f88326f0f71f27a0bafe4a678bfd4
BLAKE2b-256 70a0fe9744d70d9708847898d7f8603209c5e228f954786f7152b31cf0391622

See more details on using hashes here.

File details

Details for the file glslt-0.4.2-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: glslt-0.4.2-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 799.8 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for glslt-0.4.2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ae4d5c55e7dce25dee9342b283e55a2a5a31fbd2d87977aeedd923834f7ebb2f
MD5 b40a1dce3a4d5c0fbea90942052b75fb
BLAKE2b-256 99ee4f348c8928b76272e55f65ed1e3ff30b6c4adbe2cb948b0160f8ea24a86e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page