#webgl #web

no-std gl_matrix

A Rust implementation of glMatrix

1 unstable release

0.0.2 May 3, 2020
0.0.1 May 2, 2020

#603 in WebAssembly

Download history 8/week @ 2024-02-19 21/week @ 2024-02-26 5/week @ 2024-03-04 10/week @ 2024-03-11 58/week @ 2024-04-01

69 downloads per month

MIT license

300KB
7.5K SLoC

gl-matrix

Build Status Coverage Status Crate API

A Rust implementation of glMatrix

gl_matrix provides utilities or all glMatrix functions in Rust.

Quick Start

Getting started should be easy if you are already familiar with glMatrix and Rust. All functions have been re-named to be idiomatic Rust.

use gl_matrix::common::*;
use gl_matrix::{vec3, mat4};

let canvas_w = 800_f32; 
let canvas_h = 600_f32;
 
let mut world_matrix: Mat4 = [0.; 16];
let mut view_matrix: Mat4 = [0.; 16];
let mut proj_matrix: Mat4 = [0.; 16];

let eye = vec3::from_values(0., 0., -8.);
let center = vec3::from_values(0., 0., 0.); 
let up = vec3::from_values(0., 1., 0.);

mat4::identity(&mut world_matrix);
mat4::look_at(&mut view_matrix, &eye, &center, &up);
mat4::perspective(&mut proj_matrix, to_radian(45.), canvas_w / canvas_h, 0.1, Some(100.0));

Features

  • No std
  • Compiles to wasm
  • Familar syntax

Future work

  • Add support for f64 (Currently only f32)
  • Add support for forEach

Examples

Learning Rust WebGL

Usage

Add this to your Cargo.toml:

[dependencies]
gl_matrix = 0.0

Contributing

See CONTRIBUTING.md

License

gl-matrix is under the terms of the MIT license.

LICENSE

Dependencies

~520KB