• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust-like syntax for OpenGL Shading Language

Rust-like syntax for GLSL

Build Status

glassful translates a small subset of Rust to OpenGL Shading Language.

Besides one's personal preferences regarding Rust-like vs. C-like syntax, this has a few specific advantages for the Rust programmer:

  • Syntax is checked at Rust compile time, with friendly rustc-style errors
  • There's less cognitive overhead switching between CPU and GPU code
  • Shaders can use Rust macros!
  • Shaders embedded in a Rust program have syntax highlighting

The library is still in a very early stage! Many improvements are possible. See the issue tracker and don't hesitate to send pull requests :)

Usage

There are three ways to invoke the translator. The language syntax is exactly the same in all three cases.

As a macro

#![feature(plugin)]

#![plugin(glassful_macros)]

const VERTEX: &'static str = glassful! {
    #![version="110"]

    #[attribute] static position: vec2 = UNINIT;
    #[varying]   static color:    vec3 = UNINIT;

    fn main() {
        gl_Position = vec4(position, 0.0, 1.0);
        color = vec3(0.5*(position + vec2(1.0, 1.0)), 0.0);
    }
};

const FRAGMENT: &'static str = glassful! {
    #![version="110"]

    #[varying] static color: vec3 = UNINIT;

    fn main() {
        gl_FragColor = vec4(color, 1.0);
    }
};

let program = glium::Program::from_source(&display, VERTEX, FRAGMENT, None);

See examples/gradient/ for a full glium/glutin example.

As an external program

$ ./target/glassful < shader.glassful > shader.glsl

As an ordinary library

extern crate glassful;

pub fn main() {
    let prog = io::stdin().read_to_end().unwrap();
    let prog = String::from_utf8(prog).unwrap();
    print!("{}", glassful::translate(prog));
}

More Repositories

1

aesni-examples

Example code for the AES crypto instructions on Intel chips
Assembly
73
star
2

rpi-battery-monitor

Monitor battery voltage from a Raspberry Pi
Rust
68
star
3

rustic-symmetries

Cheat sheet for concepts in Rust which come in matching sets or have some pleasing symmetry
67
star
4

alameda

Linux kernel JIT spray for SMEP / KERNEXEC bypass
C
54
star
5

embedded-breakpoints

Embed GDB breakpoints in C source code
C
51
star
6

launch-code

Cryptographic signatures for auditing unsafe code in Rust
Rust
49
star
7

tiny-rust-demo

Using Rust to make a 151-byte static AMD64 Linux binary
Assembly
49
star
8

qoppa

Metacircular evaluator for a tiny fexpr language
Scheme
41
star
9

urpc

Tiny RPC framework for Rust
Rust
33
star
10

sliderust

Write slides in rustdoc and view them in Servo or any browser!
JavaScript
32
star
11

seqloq

rwlock with writer priority and optimistic reads
Rust
28
star
12

literator

Rust macros for container initialization and iterator literals
Rust
26
star
13

taralli

Screen edge pointer wrapping for X
C
23
star
14

travis-doc-upload

A more secure recipe for uploading Rust docs to GitHub Pages
Shell
20
star
15

blog-misc

Miscellaneous files from my blog
Haskell
19
star
16

azurescens

Renders interactive fractal-like animations
Rust
18
star
17

phosphene

fractal video feedback demo as a PC master boot record
Assembly
16
star
18

hdis86

Haskell interface to the udis86 disassembler for x86 and x86-64 / AMD64
C
14
star
19

dynamodule

Experimental dynamic OOP framework for Rust
Rust
14
star
20

autoharden

Automatic binary hardening with Autoconf
Shell
14
star
21

math-compose

X compose key bindings for mathematics, etc
Haskell
13
star
22

pngbox

Demo: OS sandboxing for unsafe code in Rust
Rust
13
star
23

vgrs

Valgrind client requests for Rust
Rust
13
star
24

sat

Interface for defining and solving SAT problems in Rust
Rust
12
star
25

breakfast

minimal breakpoints library for x86 Linux
C
11
star
26

shqq

Embed shell commands with interpolated Haskell variables, and capture output
Haskell
10
star
27

rip

Arbitrary computation on x86 without using registers
C
8
star
28

dewdrop

Find gadgets for return-oriented programming on x86
Haskell
8
star
29

spawn

A tiny Haskell library for concurrent computations
Haskell
7
star
30

tracepoints

Demo of self-modifying code in quasi-C
C
7
star
31

cccallcc

call/cc for C++
C++
5
star
32

propane

Functional synthesis of images and animations
Haskell
4
star
33

haskell-re2

Haskell (and C) interface to the RE2 regular expression library
Haskell
4
star
34

ocb.rs

Rust bindings for OCB authenticryption (AEAD) mode
C
4
star
35

concorde

Haskell interface to the Concorde solver for the Traveling Salesperson Problem
Haskell
4
star
36

hexquote

Hexadecimal ByteString literals, with placeholders that bind variables
Haskell
3
star
37

gcode

Haskell library to produce G-code, used to control CNC equipment
Haskell
3
star
38

detrospector

Markov chain text generator
Haskell
3
star
39

safe-globals

Safe top-level mutable variables for Haskell, which scope like ordinary values
Haskell
3
star
40

spool

Convert between ByteString and Vector.Storable without copying
Haskell
3
star
41

jvflife

Homebrew code for the JVF 2010-A LED sign; Game of Life demo
C
3
star
42

gc-models

Garbage collector models in Alloy
Alloy
2
star
43

kmcallister.github.io

HTML
2
star
44

forkallcc

fork(2)-based continuations for Rust
Rust
2
star
45

fixed-size-array

Rust trait for working with fixed size arrays
Rust
2
star
46

modela-utils

Utilities for milling circuit boards with the Modela MDX-20
Python
2
star
47

posix-escape

Quote arguments to be passed through the Unix shell
Haskell
2
star
48

minrisc

Minimal RISC-V emulator
Rust
1
star
49

global-lock

Provides a single global lock for Haskell code, implemented without unsafePerformIO
Haskell
1
star
50

clogparse

Parse IRC logs, such as the #haskell logs on tunes.org
Haskell
1
star
51

yices-easy

Simple interface from Haskell to the Yices SMT (SAT modulo theories) solver
Haskell
1
star