From b8498b827b54a3765bf9d1183c595880f30e7c85 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 16 Nov 2012 16:21:44 +1000 Subject: [PATCH] Move OpenGL type aliases to separate module --- src/gl.rs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mat.rs | 29 ------------------------- src/quat.rs | 6 ------ src/vec.rs | 22 ------------------- 4 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 src/gl.rs diff --git a/src/gl.rs b/src/gl.rs new file mode 100644 index 0000000..d2fc30f --- /dev/null +++ b/src/gl.rs @@ -0,0 +1,62 @@ +pub use mat::{Mat2, Mat3, Mat4}; +pub use vec::{Vec2, Vec3, Vec4}; +pub use quat::Quat; + + +// Vector aliases + +pub type vec2 = Vec2; /// a two-component single-precision floating-point vector +pub type vec3 = Vec3; /// a three-component single-precision floating-point vector +pub type vec4 = Vec4; /// a four-component single-precision floating-point vector + +pub type dvec2 = Vec2; /// a two-component double-precision floating-point vector +pub type dvec3 = Vec3; /// a three-component double-precision floating-point vector +pub type dvec4 = Vec4; /// a four-component double-precision floating-point vector + +pub type bvec2 = Vec2; /// a two-component Boolean vector +pub type bvec3 = Vec3; /// a three-component Boolean vector +pub type bvec4 = Vec4; /// a four-component Boolean vector + +pub type ivec2 = Vec2; /// a two-component signed integer vector +pub type ivec3 = Vec3; /// a three-component signed integer vector +pub type ivec4 = Vec4; /// a four-component signed integer vector + +pub type uvec2 = Vec2; /// a two-component unsigned integer vector +pub type uvec3 = Vec3; /// a three-component unsigned integer vector +pub type uvec4 = Vec4; /// a four-component unsigned integer vector + + +// Matrix aliases + +pub type mat2 = Mat2; /// a 2×2 single-precision floating-point matrix +pub type mat3 = Mat3; /// a 3×3 single-precision floating-point matrix +pub type mat4 = Mat4; /// a 4×4 single-precision floating-point matrix +pub type mat2x2 = Mat2; /// same as a `mat2` +// pub type mat2x3 = /// a single-precision floating-point matrix with 2 columns and 3 rows +// pub type mat2x4 = /// a single-precision floating-point matrix with 2 columns and 4 rows +// pub type mat3x2 = /// a single-precision floating-point matrix with 3 columns and 2 rows +pub type mat3x3 = Mat3; /// same as a `mat3` +// pub type mat3x4 = /// a single-precision floating-point matrix with 3 columns and 4 rows +// pub type mat4x2 = /// a single-precision floating-point matrix with 4 columns and 2 rows +// pub type mat4x3 = /// a single-precision floating-point matrix with 4 columns and 3 rows +pub type mat4x4 = Mat4; /// same as a `mat4` + +pub type dmat2 = Mat2; /// a 2×2 double-precision floating-point matrix +pub type dmat3 = Mat3; /// a 3×3 double-precision floating-point matrix +pub type dmat4 = Mat4; /// a 4×4 double-precision floating-point matrix +pub type dmat2x2 = Mat2; /// same as a `dmat2` +// pub type dmat2x3 = /// a double-precision floating-point matrix with 2 columns and 3 rows +// pub type dmat2x4 = /// a double-precision floating-point matrix with 2 columns and 4 rows +// pub type dmat3x2 = /// a double-precision floating-point matrix with 3 columns and 2 rows +pub type dmat3x3 = Mat3; /// same as a `dmat3` +// pub type dmat3x4 = /// a double-precision floating-point matrix with 3 columns and 4 rows +// pub type dmat4x2 = /// a double-precision floating-point matrix with 4 columns and 2 rows +// pub type dmat4x3 = /// a double-precision floating-point matrix with 4 columns and 3 rows +pub type dmat4x4 = Mat4; /// same as a `dmat4` + + +// These quaternion type aliases are not actually specified in the GLSL spec +// but they follow the same nomenclature + +pub type quat4 = Quat; /// a single-precision floating-point quaternion +pub type dquat4 = Quat; /// a double-precision floating-point quaternion \ No newline at end of file diff --git a/src/mat.rs b/src/mat.rs index b7a552a..df08ceb 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -14,35 +14,6 @@ use quat::{Quat, ToQuat}; use vec::{Vec2, Vec3, Vec4}; -// GLSL equivalent type aliases - -pub type mat2 = Mat2; /// a 2×2 single-precision floating-point matrix -pub type mat3 = Mat3; /// a 3×3 single-precision floating-point matrix -pub type mat4 = Mat4; /// a 4×4 single-precision floating-point matrix -pub type mat2x2 = Mat2; /// same as a `mat2` -// pub type mat2x3 = /// a single-precision floating-point matrix with 2 columns and 3 rows -// pub type mat2x4 = /// a single-precision floating-point matrix with 2 columns and 4 rows -// pub type mat3x2 = /// a single-precision floating-point matrix with 3 columns and 2 rows -pub type mat3x3 = Mat3; /// same as a `mat3` -// pub type mat3x4 = /// a single-precision floating-point matrix with 3 columns and 4 rows -// pub type mat4x2 = /// a single-precision floating-point matrix with 4 columns and 2 rows -// pub type mat4x3 = /// a single-precision floating-point matrix with 4 columns and 3 rows -pub type mat4x4 = Mat4; /// same as a `mat4` - -pub type dmat2 = Mat2; /// a 2×2 double-precision floating-point matrix -pub type dmat3 = Mat3; /// a 3×3 double-precision floating-point matrix -pub type dmat4 = Mat4; /// a 4×4 double-precision floating-point matrix -pub type dmat2x2 = Mat2; /// same as a `dmat2` -// pub type dmat2x3 = /// a double-precision floating-point matrix with 2 columns and 3 rows -// pub type dmat2x4 = /// a double-precision floating-point matrix with 2 columns and 4 rows -// pub type dmat3x2 = /// a double-precision floating-point matrix with 3 columns and 2 rows -pub type dmat3x3 = Mat3; /// same as a `dmat3` -// pub type dmat3x4 = /// a double-precision floating-point matrix with 3 columns and 4 rows -// pub type dmat4x2 = /// a double-precision floating-point matrix with 4 columns and 2 rows -// pub type dmat4x3 = /// a double-precision floating-point matrix with 4 columns and 3 rows -pub type dmat4x4 = Mat4; /// same as a `dmat4` - - pub trait Matrix: Dimensional, Eq { pure fn rows() -> uint; pure fn cols() -> uint; diff --git a/src/quat.rs b/src/quat.rs index e8ecfae..8931744 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -15,12 +15,6 @@ use num::cast::*; use vec::Vec3; -// These quaternion type aliases are not actually specified in the GLSL spec -// but they follow the same nomenclature - -pub type quat4 = Quat; /// a single-precision floating-point quaternion -pub type dquat4 = Quat; /// a double-precision floating-point quaternion - // // Quaternion // diff --git a/src/vec.rs b/src/vec.rs index 8e640f2..a9c7704 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -10,28 +10,6 @@ use funs::exp::Exp; use math::*; use num::cast::*; -// GLSL equivalent type aliases - -pub type vec2 = Vec2; /// a two-component single-precision floating-point vector -pub type vec3 = Vec3; /// a three-component single-precision floating-point vector -pub type vec4 = Vec4; /// a four-component single-precision floating-point vector - -pub type dvec2 = Vec2; /// a two-component double-precision floating-point vector -pub type dvec3 = Vec3; /// a three-component double-precision floating-point vector -pub type dvec4 = Vec4; /// a four-component double-precision floating-point vector - -pub type bvec2 = Vec2; /// a two-component Boolean vector -pub type bvec3 = Vec3; /// a three-component Boolean vector -pub type bvec4 = Vec4; /// a four-component Boolean vector - -pub type ivec2 = Vec2; /// a two-component signed integer vector -pub type ivec3 = Vec3; /// a three-component signed integer vector -pub type ivec4 = Vec4; /// a four-component signed integer vector - -pub type uvec2 = Vec2; /// a two-component unsigned integer vector -pub type uvec3 = Vec3; /// a three-component unsigned integer vector -pub type uvec4 = Vec4; /// a four-component unsigned integer vector - pub trait Vector: Dimensional, Eq {}