#![cfg_attr(
feature = "std",
doc = r##"
```rust
use mint::{ColumnMatrix4, Vector3};
use crevice_notan::glsl::GlslStruct;
#[derive(GlslStruct)]
struct SpotLight {
transform: ColumnMatrix4<f32>,
color: Vector3<f32>,
intensity: f32,
}
println!("{}", SpotLight::glsl_definition());
```
"##
)]
pub use crevice_notan_derive::GlslStruct;
pub unsafe trait Glsl {
const NAME: &'static str;
}
pub struct GlslField {
pub ty: &'static str,
pub name: &'static str,
}
#[cfg(feature = "std")]
pub unsafe trait GlslStruct: Glsl {
const FIELDS: &'static [GlslField];
fn glsl_definition() -> String {
let mut output = String::new();
output.push_str("struct ");
output.push_str(Self::NAME);
output.push_str(" {\n");
for field in Self::FIELDS {
output.push('\t');
output.push_str(field.ty);
output.push(' ');
output.push_str(field.name);
output.push_str(";\n");
}
output.push_str("};");
output
}
}
unsafe impl Glsl for f32 {
const NAME: &'static str = "float";
}
unsafe impl Glsl for f64 {
const NAME: &'static str = "double";
}
unsafe impl Glsl for i32 {
const NAME: &'static str = "int";
}
unsafe impl Glsl for u32 {
const NAME: &'static str = "uint";
}