[−][src]Crate emu_glsl
emu_glsl
is a crate for GLSL-Rust interop. Currently, it only provides
a single derive macro - glsl_struct
. This macro derives a trait that
is defined in the emu_core
crate - GlslStruct
. This is what the trait
looks like.
pub trait GlslStruct { fn as_glsl() -> String; // return the GLSL struct definition of Self }
emu_glsl
lets you derive this trait for simple structures where each
field is one of the following.
bool
i32
u32
f32
f64
[i32 | u32 | f32 | f64 | bool; 2 | 3 | 4]
These get straightforwardly translated to their GLSL equivalents with
the arrays being translated to GLSL "vector data types". An example usage
is the following. (It doesn't compile as is because it's missing imports for the
GlslStruct
trait and glsl_struct
derive macro.)
ⓘThis example deliberately fails to compile
#[derive(GlslStruct)] struct Polygon { num_edges: u32, radius: f64, conv: bool, // make sure polygons in same thread block have same convexity }
Derive Macros
GlslStruct |