Skip to content

HoloTheDrunk/glrs

Repository files navigation

Making Rust and OpenGL kiss

GitHub Crates.io Docs.rs Continuous Integration

Passing data between Rust and OpenGL is error-prone and mistakes can be hard to debug.

This crate provides compile-time conversion of GLSL constructs to Rust based on the glam crate.

[dependencies]
glrs = "0.1"

Only tested on rustc 1.75, MSRV may be lower.

Roadmap

  • Layout aware importing
    • Add padding bytes according to GLSL spec's defined layout modes
  • Structs
    • Basic struct importing
    • Nested struct importing?
  • Uniforms
    • Single file uniforms importing
    • Full shader chain uniforms checking and importing
  • Defines
    • Single file defines importing (possible collisions when importing from multiple ones)
  • Interface blocks

Importing a struct

shaders/utils.glsl

struct Player {
  vec3 pos;
  vec3 speed;
};

src/main.rs

#[glrs::import(path = "shaders/utils.glsl", name = "Player")]
#[derive(Debug)]
struct GlPlayer;

fn main() {
    dbg!(GlPlayer {
        pos: glam::vec3(0., 0., 0.),
        speed: glam::vec3(0., 0., 0.),
    });
}

About

Compile-time conversion of GLSL structs to glam Rust structs.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published