• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Rust
  • Created over 2 years ago
  • Updated 5 months ago

Reviews

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

Repository Details

Type-Safe Graphics Programming with Functional Shaders

posh

posh is a type-safe OpenGL ES 3.0 wrapper library with the aim of making graphics programming enjoyable. posh consists of a graphics library (posh::gl) and a shading language (posh::sl), which are tightly integrated in a single crate.

If you want to learn more about the concepts used by posh, check out our blog post.

Here's the typical shape of posh code. Shaders are written in normal Rust code, so their type signature naturally becomes part of the program that is used for performing type-safe draw calls.

use posh::{gl, sl};

// ... define custom shader interface types U, V, W, and F ...

fn vertex_shader(uniform: U, vertex: V) -> sl::VsOutput<W> {
    // ... compute `sl::VsOutput { clip_position, interpolant }` ...
}

fn fragment_shader(uniform: U, interpolant: W) -> F {
    // ... compute F ...
}

let program: gl::Program<U, V, F> = gl.create_program(
    vertex_shader,
    fragment_shader,
)?;

program
    .with_uniforms(/* uniform bindings matching U */)
    .with_framebuffer(/* framebuffer matching F */)
    .with_settings(/* draw settings */)
    .draw(/* vertex specification matching V */)?;

Status

posh is in an early alpha stage. Use with caution. Contributions are welcome!

Scope

The initial scope of posh is limited intentionally. It targets a subset of OpenGL ES 3.0 and GLSL ES 3.00.

These restrictions can be lifted over time. A second iteration of posh could e.g. target a subset of wgpu rather than OpenGL.

Related Work

The following awesome crates are closely related to the aims of posh:

  • Shades is an EDSL for statically-typed shaders.

  • rust-gpu is a compiler backend for rustc that generates SPIR-V.

The main difference to these is that posh tightly integrates its shading language (an embedded domain-specific language) with its graphics library in a single crate.

More Repositories

1

hncynic

Generate Hacker News Comments from Titles
Python
333
star
2

rendology

Glium-based 3D rendering pipeline
Rust
64
star
3

ultimate-scale

Build increasingly large machines to solve increasingly difficult problems
Rust
61
star
4

pareen

Rust library for parameterized inbetweening
Rust
51
star
5

malen

Rust
12
star
6

coarse-prof

Tiny library for coarse-grained hierarchical profiling in Rust
Rust
10
star
7

catcheb

Secret multiplayer browser game
Rust
9
star
8

particle-frenzy

Simple 2D particle system in Rust
Rust
5
star
9

aural-travels

Turn Album Covers Into Music If You Want To Do That For Some Reason
Jupyter Notebook
3
star
10

catch-rs

Rust
2
star
11

hooks

Multiplayer catching game
Rust
1
star
12

flow

Rust
1
star
13

lang

A compiler for a language. Written in C++. Using LLVM. That's all I know for now.
C++
1
star
14

leod.github.io

Ruby
1
star
15

netgame

Rust
1
star
16

scdata

Jupyter Notebook
1
star
17

shady

Rust
1
star
18

configs

My various linux configs
Vim Script
1
star
19

untimely

Rust
1
star
20

exponentially_slow_compile

Rust
1
star
21

dotfiles

Linux Dotfiles
Shell
1
star
22

glace

OpenGL with Icing
Rust
1
star
23

stecs

Static entities; components static (i.e. stecs)
Rust
1
star
24

wosh

posh on wgpu
Rust
1
star
25

defend

Backup of some code from around 2009-2010 I think
D
1
star
26

shadergoo

Rust
1
star
27

haskell-rpg2d

haskell-rpg2d is an attempt by a Haskell newbie to write a relatively simple 2D RPG in Haskell
Haskell
1
star
28

nndefense

Rust
1
star
29

destiny

Rust
1
star
30

cereal

A simple cerealisation library
Rust
1
star
31

jlogic

Very inefficient interpreter for a very small subset of Prolog (for learning purposes)
Java
1
star
32

tmart

TM generated 2D art
C
1
star
33

albumlist

A mixture of hacks to create an overview over my music library combining MPD, Last.fm and more. Don't try this at home.
Python
1
star
34

bit_manager

Fork of Scott Taylor's bit_manager (https://crates.io/crates/bit_manager)
Rust
1
star