5 releases

0.1.4 Oct 12, 2024
0.1.3 Oct 1, 2022
0.1.2 Jul 3, 2022
0.1.1 Jul 2, 2022
0.1.0 Jun 28, 2022

#1603 in Procedural macros

33 downloads per month
Used in webgl-rc

MIT license

12KB
292 lines

GLSL Loader for webgl-rc

Shader file

/* include absolute path 'project_dir/glsl/lib/color.glsl'  */
#include <lib/color.glsl>

/* include relative path './common/bezier.glsl' */
#include "./common/bezier.glsl"

void main() {
    ...
}

Rust file

use webgl_rc::load_glsl;

const fragment_source: &str = load_glsl!("fragment.glsl");


lib.rs:

GLSL Loading Macro

[load_glsl] macro is similar to std::include_str but it has some differences:

  • it loads files from glsl directory at the project root,
  • it supports #include <lib/color.glsl> or #incluide "../lib/color.glsl" macro in the files.

Dependencies

~2.2–3MB
~54K SLoC