#GLSL #OpenGL #SPIR-V #parser #proc-macro

nightly macro glsl-quasiquote

The glsl! procedural macro, providing quasiquoting of the glsl crate

3 unstable releases

0.2.0 Oct 21, 2018
0.1.1 Oct 10, 2018
0.1.0 Oct 5, 2018

#5 in #spir-v

Download history 20/week @ 2018-10-11 35/week @ 2018-10-18 12/week @ 2018-10-25 13/week @ 2018-11-01 42/week @ 2018-11-08 71/week @ 2018-11-15 16/week @ 2018-11-22

23 downloads per month

BSD-3-Clause

52KB
976 lines

GLSL quasiquoting.

This crate exports a procedural macro: glsl!. It enables quasiquoting by allowing you to embed GLSL source code directly into rust via the syntax:

glsl!{
  // your GLSL code here
  void main() {
  }
}

! The glsl! macro accepts the GLSL code directly. You can then write plain GLSL. Especially, ! since version 0.2, the macro accepts plain GLSL pragmas (both #version and #extension).

The glsl! procedural macro resolves at compile-time to glsl::syntax::TranslationUnit, allowing you to manipulate the GLSL AST directly. Feel free to have a look at the glsl crate for further information.

Getting started

Add the following to your dependencies in your Cargo.toml:

glsl = "0.11"
glsl-quasiquote = "0.2"

Then, you currently need to have a nightly compiler and the following feature enabled:

#![feature(proc_macro_hygiene)]

Then, depending on which you’re using the 2018 edition or not:

Non-2018 edition

extern crate glsl;
#[macro_use] extern crate glsl_quasiquote;

2018 edition

extern crate glsl;
use glsl_quasiquote::glsl;

Dependencies

~1MB
~23K SLoC