| Crates.io | glamour |
| lib.rs | glamour |
| version | 0.18.0 |
| created_at | 2022-04-04 05:50:09.857987+00 |
| updated_at | 2025-05-08 07:09:55.92593+00 |
| description | Strongly typed linear algebra with glam |
| homepage | https://docs.rs/glamour/latest/glamour/ |
| repository | https://github.com/simonask/glamour |
| max_upload_size | |
| id | 561837 |
| size | 647,240 |
glamThis crate uses bytemuck to implement a zero-cost1 strongly typed interface on top of glam.
The API is similar to euclid, but more ergonomic (although YMMV).
One of the API design goals of glam is to avoid complexity by not going
bananas with traits and generics. This crate is the opposite. But it does
allow you to easily drop down to plain glam when needed.
See the docs module for detailed documentation.
Unit] for that struct. [Unit::Scalar] determines the primitive
type used in vector components.f32, f64, i32, u32, i64, u64, i16, or u16.use glamour::prelude::*;
struct MyUnit;
impl Unit for MyUnit {
type Scalar = f32;
}
// Start using your new unit:
let vector: Vector4<MyUnit> = Vector4 { x: 1.0, y: 2.0, z: 3.0, w: 4.0 };
let size: Size2<MyUnit> = Size2 { width: 100.0, height: 200.0 };
// Use untyped units when needed:
let vector_untyped: &Vector4<f32> = vector.as_untyped();
// Use glam when needed:
let vector_raw: glam::Vec4 = vector.to_raw();
See the documentation module for more examples.
std - enables the glam/std feature. Enabled by default.libm - required to compile with no_std (transitively enables glam/no_std).mint - enables conversion to/from
mint types.encase: Enables implementations of [encase::ShaderType] for vector and matrix types, which enables them for use in
GPU shaders.scalar-math: Don't use SIMD vector instructions, even if they are supported by the target architecture. Note that
this flag is required to run tests under Miri, due to vector instructions not being supported. Transitively enables
the glam/scalar-math feature.wasmtime: (Experimental) This enables implementations of Lower/Lift
on all types, so they can be used in generated bindings for WIT components
(wasmtime::component::bindgen!()). Glamour types can be used on both sides
(host and guest), and can be passed "toll-free" between the two sides given a
compatible type declaration in a WIT world, but limitations apply: Due to the
way the wasmtime derive macros work, only plain scalar units can be used (so
Vector4<f32> is supported, but not Vector4<MyFloatUnit>).facet: (Experimental) Adds support for
facet to all types.Size2] are called width and
height, rather than x and y.glam types when needed.glameuclidbytemuck.glamglam is a very approachable API.glam is able to support a wide range of transformation primitives (e.g.
[glam::Affine3A], [glam::Quat], etc.), and the user has a lot of
flexibility to choose the most performant kind for their use case. These are
simply unimplemented in glamour.euclidUnit].glam.no_std.glam API conventions - "principle of least surprise".glam directly).
Comprehensive benchmarks pending.glam).glam API. Instead, we make it really easy (and
performant) to drop down to glam types when needed.glam API. It's OK to use glam types in public APIs.AoSoA" pattern ("extra wide" vector types). Use ultraviolet
instead.All operations should perform exactly the same as their glam counterparts.
There is a zero-tolerance policy for overhead in release builds.
However, debug build performance is also important in some cases. For example, for a video game it can make the difference between being playable or not in debug mode.
This crate should be expected to incur an overhead of about a factor 2 compared
to glam in debug builds. This may be alleviated in the future, but it seems
that even glam itself does not go out of its way to perform well in debug
builds.
Zero-cost at runtime, in release builds. This crate may increase compile times and make debug builds slower due to increased code size. ↩