#glsl #opengl #glsl-shader

glossy_codegen

Build dependency for glossy, a compile-time GLSL shader loader with #include support

1 unstable release

Uses old Rust 2015

0.2.0 Oct 25, 2016

#34 in #glsl-shader

MPL-2.0 license

21KB
410 lines

glossy

A GLSL source loading crate for Rust which supports the #include directive and shader optimization at compile time via glsl-optimizer.

Example Usage

In build script build.rs:

extern crate glossy_codegen as glsl;

void main() {
    glsl::Config::new(glsl::Language::OpenGl)
        .vertex("shaders/*.vert")
        .fragment("shaders/*.frag")
        .include("shaders/include/*")
        .optimize()
        .build();
}

In Rust source file main.rs:

#[macro_use]
extern crate glossy;
extern crate glium;

void main() {
    // ...
    glium::Program::from_source(gl,
                                shader!("sprite.vert"),
                                shader!("sprite.frag"),
                                None)
        .unwrap();
    // ...
}

In shader source file shader.frag:

#version 120
#include "common.glsl"

void main() {
    float v = common_func(common_uniform);
    // ...
}

lib.rs:

This is the code generation/build script component of glossy.

Refer to the glossy module for more details.

Dependencies

~4.5MB
~93K SLoC