1#![allow(non_camel_case_types)]
2
3use std::fmt;
119use std::ops::{Deref, DerefMut, Index, IndexMut};
120
121pub use std140_macros::repr_std140;
138
139pub unsafe trait ReprStd140 {}
144
145pub unsafe trait Std140ArrayElement: ReprStd140 {}
147
148pub unsafe trait Std140Struct {}
152
153unsafe impl<T> ReprStd140 for T where T: Std140Struct {}
154unsafe impl<T> Std140ArrayElement for T where T: Std140Struct {}
155
156#[derive(Clone, Copy)]
171pub struct array<T, const LEN: usize>
172where
173 T: Std140ArrayElement,
174{
175 internal: [ArrayElementWrapper<T>; LEN],
176}
177
178impl<T, const LEN: usize> array<T, { LEN }>
179where
180 T: Std140ArrayElement,
181{
182 #[doc(hidden)]
183 pub fn from_wrapped(wrapped: [ArrayElementWrapper<T>; LEN]) -> Self {
184 array { internal: wrapped }
185 }
186}
187
188impl<T, const LEN: usize> PartialEq for array<T, { LEN }>
189where
190 T: Std140ArrayElement + PartialEq,
191{
192 fn eq(&self, other: &Self) -> bool {
193 for i in 0..LEN {
194 if self.internal[i] != other.internal[i] {
195 return false;
196 }
197 }
198
199 true
200 }
201}
202
203impl<T, const LEN: usize> fmt::Debug for array<T, { LEN }>
204where
205 T: Std140ArrayElement + fmt::Debug,
206{
207 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
208 f.debug_list().entries(self.internal.iter()).finish()
209 }
210}
211
212#[doc(hidden)]
220#[derive(Clone, Copy, PartialEq, Eq, Hash)]
221#[repr(C, align(16))]
222pub struct ArrayElementWrapper<T>
223where
224 T: Std140ArrayElement,
225{
226 pub element: T,
227}
228
229impl<T> fmt::Debug for ArrayElementWrapper<T>
230where
231 T: Std140ArrayElement + fmt::Debug,
232{
233 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
234 <T as fmt::Debug>::fmt(&self.element, f)
235 }
236}
237
238#[macro_export]
249macro_rules! array {
250 ($elem:expr; $n:expr) => {
251 $crate::array::from_wrapped([$crate::ArrayElementWrapper {
252 element: $elem
253 }; $n])
254 };
255 ($($x:expr),*) => {
256 $crate::array::from_wrapped([
257 $(
258 $crate::ArrayElementWrapper {
259 element: $x
260 }
261 ),*
262 ])
263 };
264 ($($x:expr,)*) => ($crate::array![$($x),*])
265}
266
267unsafe impl<T, const LEN: usize> ReprStd140 for array<T, { LEN }> where T: Std140ArrayElement {}
268
269#[repr(C, align(4))]
277#[derive(Clone, Copy, PartialEq, Debug)]
278pub struct float(pub f32);
279
280unsafe impl ReprStd140 for float {}
281unsafe impl Std140ArrayElement for float {}
282
283#[repr(C, align(8))]
291#[derive(Clone, Copy, PartialEq, Debug)]
292pub struct vec2(pub f32, pub f32);
293
294impl vec2 {
295 pub fn zero() -> Self {
297 vec2(0.0, 0.0)
298 }
299}
300
301unsafe impl ReprStd140 for vec2 {}
302unsafe impl Std140ArrayElement for vec2 {}
303
304impl Index<usize> for vec2 {
305 type Output = f32;
306
307 fn index(&self, index: usize) -> &Self::Output {
308 match index {
309 0 => &self.0,
310 1 => &self.1,
311 _ => panic!("Index out of bounds"),
312 }
313 }
314}
315
316impl IndexMut<usize> for vec2 {
317 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
318 match index {
319 0 => &mut self.0,
320 1 => &mut self.1,
321 _ => panic!("Index out of bounds"),
322 }
323 }
324}
325
326#[repr(C, align(16))]
334#[derive(Clone, Copy, PartialEq, Debug)]
335pub struct vec3(pub f32, pub f32, pub f32);
336
337impl vec3 {
338 pub fn zero() -> Self {
340 vec3(0.0, 0.0, 0.0)
341 }
342}
343
344unsafe impl ReprStd140 for vec3 {}
345unsafe impl Std140ArrayElement for vec3 {}
346
347impl Index<usize> for vec3 {
348 type Output = f32;
349
350 fn index(&self, index: usize) -> &Self::Output {
351 match index {
352 0 => &self.0,
353 1 => &self.1,
354 2 => &self.2,
355 _ => panic!("Index out of bounds"),
356 }
357 }
358}
359
360impl IndexMut<usize> for vec3 {
361 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
362 match index {
363 0 => &mut self.0,
364 1 => &mut self.1,
365 2 => &mut self.2,
366 _ => panic!("Index out of bounds"),
367 }
368 }
369}
370
371#[repr(C, align(16))]
379#[derive(Clone, Copy, PartialEq, Debug)]
380pub struct vec4(pub f32, pub f32, pub f32, pub f32);
381
382impl vec4 {
383 pub fn zero() -> Self {
385 vec4(0.0, 0.0, 0.0, 0.0)
386 }
387}
388
389unsafe impl ReprStd140 for vec4 {}
390unsafe impl Std140ArrayElement for vec4 {}
391
392impl Index<usize> for vec4 {
393 type Output = f32;
394
395 fn index(&self, index: usize) -> &Self::Output {
396 match index {
397 0 => &self.0,
398 1 => &self.1,
399 2 => &self.2,
400 3 => &self.3,
401 _ => panic!("Index out of bounds"),
402 }
403 }
404}
405
406impl IndexMut<usize> for vec4 {
407 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
408 match index {
409 0 => &mut self.0,
410 1 => &mut self.1,
411 2 => &mut self.2,
412 3 => &mut self.3,
413 _ => panic!("Index out of bounds"),
414 }
415 }
416}
417
418#[repr(C, align(4))]
426#[derive(Clone, Copy, PartialEq, Debug)]
427pub struct int(pub i32);
428
429unsafe impl ReprStd140 for int {}
430unsafe impl Std140ArrayElement for int {}
431
432#[repr(C, align(8))]
440#[derive(Clone, Copy, PartialEq, Debug)]
441pub struct ivec2(pub i32, pub i32);
442
443impl ivec2 {
444 pub fn zero() -> Self {
446 ivec2(0, 0)
447 }
448}
449
450unsafe impl ReprStd140 for ivec2 {}
451unsafe impl Std140ArrayElement for ivec2 {}
452
453impl Index<usize> for ivec2 {
454 type Output = i32;
455
456 fn index(&self, index: usize) -> &Self::Output {
457 match index {
458 0 => &self.0,
459 1 => &self.1,
460 _ => panic!("Index out of bounds"),
461 }
462 }
463}
464
465impl IndexMut<usize> for ivec2 {
466 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
467 match index {
468 0 => &mut self.0,
469 1 => &mut self.1,
470 _ => panic!("Index out of bounds"),
471 }
472 }
473}
474
475#[repr(C, align(16))]
483#[derive(Clone, Copy, PartialEq, Debug)]
484pub struct ivec3(pub i32, pub i32, pub i32);
485
486impl ivec3 {
487 pub fn zero() -> Self {
489 ivec3(0, 0, 0)
490 }
491}
492
493unsafe impl ReprStd140 for ivec3 {}
494unsafe impl Std140ArrayElement for ivec3 {}
495
496impl Index<usize> for ivec3 {
497 type Output = i32;
498
499 fn index(&self, index: usize) -> &Self::Output {
500 match index {
501 0 => &self.0,
502 1 => &self.1,
503 2 => &self.2,
504 _ => panic!("Index out of bounds"),
505 }
506 }
507}
508
509impl IndexMut<usize> for ivec3 {
510 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
511 match index {
512 0 => &mut self.0,
513 1 => &mut self.1,
514 2 => &mut self.2,
515 _ => panic!("Index out of bounds"),
516 }
517 }
518}
519
520#[repr(C, align(16))]
528#[derive(Clone, Copy, PartialEq, Debug)]
529pub struct ivec4(pub i32, pub i32, pub i32, pub i32);
530
531impl ivec4 {
532 pub fn zero() -> Self {
534 ivec4(0, 0, 0, 0)
535 }
536}
537
538unsafe impl ReprStd140 for ivec4 {}
539unsafe impl Std140ArrayElement for ivec4 {}
540
541impl Index<usize> for ivec4 {
542 type Output = i32;
543
544 fn index(&self, index: usize) -> &Self::Output {
545 match index {
546 0 => &self.0,
547 1 => &self.1,
548 2 => &self.2,
549 3 => &self.3,
550 _ => panic!("Index out of bounds"),
551 }
552 }
553}
554
555impl IndexMut<usize> for ivec4 {
556 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
557 match index {
558 0 => &mut self.0,
559 1 => &mut self.1,
560 2 => &mut self.2,
561 3 => &mut self.3,
562 _ => panic!("Index out of bounds"),
563 }
564 }
565}
566
567#[repr(C, align(4))]
575#[derive(Clone, Copy, PartialEq, Debug)]
576pub struct uint(pub u32);
577
578unsafe impl ReprStd140 for uint {}
579unsafe impl Std140ArrayElement for uint {}
580
581#[repr(C, align(8))]
589#[derive(Clone, Copy, PartialEq, Debug)]
590pub struct uvec2(pub u32, pub u32);
591
592impl uvec2 {
593 pub fn zero() -> Self {
595 uvec2(0, 0)
596 }
597}
598
599unsafe impl ReprStd140 for uvec2 {}
600unsafe impl Std140ArrayElement for uvec2 {}
601
602impl Index<usize> for uvec2 {
603 type Output = u32;
604
605 fn index(&self, index: usize) -> &Self::Output {
606 match index {
607 0 => &self.0,
608 1 => &self.1,
609 _ => panic!("Index out of bounds"),
610 }
611 }
612}
613
614impl IndexMut<usize> for uvec2 {
615 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
616 match index {
617 0 => &mut self.0,
618 1 => &mut self.1,
619 _ => panic!("Index out of bounds"),
620 }
621 }
622}
623
624#[repr(C, align(16))]
632#[derive(Clone, Copy, PartialEq, Debug)]
633pub struct uvec3(pub u32, pub u32, pub u32);
634
635impl uvec3 {
636 pub fn zero() -> Self {
638 uvec3(0, 0, 0)
639 }
640}
641
642unsafe impl ReprStd140 for uvec3 {}
643unsafe impl Std140ArrayElement for uvec3 {}
644
645impl Index<usize> for uvec3 {
646 type Output = u32;
647
648 fn index(&self, index: usize) -> &Self::Output {
649 match index {
650 0 => &self.0,
651 1 => &self.1,
652 2 => &self.2,
653 _ => panic!("Index out of bounds"),
654 }
655 }
656}
657
658impl IndexMut<usize> for uvec3 {
659 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
660 match index {
661 0 => &mut self.0,
662 1 => &mut self.1,
663 2 => &mut self.2,
664 _ => panic!("Index out of bounds"),
665 }
666 }
667}
668
669#[repr(C, align(16))]
677#[derive(Clone, Copy, PartialEq, Debug)]
678pub struct uvec4(pub u32, pub u32, pub u32, pub u32);
679
680impl uvec4 {
681 pub fn zero() -> Self {
683 uvec4(0, 0, 0, 0)
684 }
685}
686
687unsafe impl ReprStd140 for uvec4 {}
688unsafe impl Std140ArrayElement for uvec4 {}
689
690impl Index<usize> for uvec4 {
691 type Output = u32;
692
693 fn index(&self, index: usize) -> &Self::Output {
694 match index {
695 0 => &self.0,
696 1 => &self.1,
697 2 => &self.2,
698 3 => &self.3,
699 _ => panic!("Index out of bounds"),
700 }
701 }
702}
703
704impl IndexMut<usize> for uvec4 {
705 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
706 match index {
707 0 => &mut self.0,
708 1 => &mut self.1,
709 2 => &mut self.2,
710 3 => &mut self.3,
711 _ => panic!("Index out of bounds"),
712 }
713 }
714}
715
716#[repr(u32)]
727#[derive(Clone, Copy, PartialEq, Debug)]
728pub enum boolean {
729 True = 1,
730 False = 0,
731}
732
733unsafe impl ReprStd140 for boolean {}
734unsafe impl Std140ArrayElement for boolean {}
735
736impl From<bool> for boolean {
737 fn from(value: bool) -> Self {
738 match value {
739 true => boolean::True,
740 false => boolean::False,
741 }
742 }
743}
744
745#[repr(C, align(8))]
753#[derive(Clone, Copy, PartialEq, Debug)]
754pub struct bvec2(pub boolean, pub boolean);
755
756unsafe impl ReprStd140 for bvec2 {}
757unsafe impl Std140ArrayElement for bvec2 {}
758
759impl Index<usize> for bvec2 {
760 type Output = boolean;
761
762 fn index(&self, index: usize) -> &Self::Output {
763 match index {
764 0 => &self.0,
765 1 => &self.1,
766 _ => panic!("Index out of bounds"),
767 }
768 }
769}
770
771impl IndexMut<usize> for bvec2 {
772 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
773 match index {
774 0 => &mut self.0,
775 1 => &mut self.1,
776 _ => panic!("Index out of bounds"),
777 }
778 }
779}
780
781#[repr(C, align(16))]
789#[derive(Clone, Copy, PartialEq, Debug)]
790pub struct bvec3(pub boolean, pub boolean, pub boolean);
791
792unsafe impl ReprStd140 for bvec3 {}
793unsafe impl Std140ArrayElement for bvec3 {}
794
795impl Index<usize> for bvec3 {
796 type Output = boolean;
797
798 fn index(&self, index: usize) -> &Self::Output {
799 match index {
800 0 => &self.0,
801 1 => &self.1,
802 2 => &self.2,
803 _ => panic!("Index out of bounds"),
804 }
805 }
806}
807
808impl IndexMut<usize> for bvec3 {
809 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
810 match index {
811 0 => &mut self.0,
812 1 => &mut self.1,
813 2 => &mut self.2,
814 _ => panic!("Index out of bounds"),
815 }
816 }
817}
818
819#[repr(C, align(16))]
832#[derive(Clone, Copy, PartialEq, Debug)]
833pub struct bvec4(pub boolean, pub boolean, pub boolean, pub boolean);
834
835unsafe impl ReprStd140 for bvec4 {}
836unsafe impl Std140ArrayElement for bvec4 {}
837
838impl Index<usize> for bvec4 {
839 type Output = boolean;
840
841 fn index(&self, index: usize) -> &Self::Output {
842 match index {
843 0 => &self.0,
844 1 => &self.1,
845 2 => &self.2,
846 3 => &self.3,
847 _ => panic!("Index out of bounds"),
848 }
849 }
850}
851
852impl IndexMut<usize> for bvec4 {
853 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
854 match index {
855 0 => &mut self.0,
856 1 => &mut self.1,
857 2 => &mut self.2,
858 3 => &mut self.3,
859 _ => panic!("Index out of bounds"),
860 }
861 }
862}
863
864#[repr(C, align(8))]
872#[derive(Clone, Copy, PartialEq, Debug)]
873pub struct double(pub f64);
874
875unsafe impl ReprStd140 for double {}
876unsafe impl Std140ArrayElement for double {}
877
878#[repr(C, align(16))]
886#[derive(Clone, Copy, PartialEq, Debug)]
887pub struct dvec2(pub f64, pub f64);
888
889impl dvec2 {
890 pub fn zero() -> Self {
892 dvec2(0.0, 0.0)
893 }
894}
895
896unsafe impl ReprStd140 for dvec2 {}
897unsafe impl Std140ArrayElement for dvec2 {}
898
899impl Index<usize> for dvec2 {
900 type Output = f64;
901
902 fn index(&self, index: usize) -> &Self::Output {
903 match index {
904 0 => &self.0,
905 1 => &self.1,
906 _ => panic!("Index out of bounds"),
907 }
908 }
909}
910
911impl IndexMut<usize> for dvec2 {
912 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
913 match index {
914 0 => &mut self.0,
915 1 => &mut self.1,
916 _ => panic!("Index out of bounds"),
917 }
918 }
919}
920
921#[repr(C, align(32))]
929#[derive(Clone, Copy, PartialEq, Debug)]
930pub struct dvec3(pub f64, pub f64, pub f64);
931
932impl dvec3 {
933 pub fn zero() -> Self {
935 dvec3(0.0, 0.0, 0.0)
936 }
937}
938
939unsafe impl ReprStd140 for dvec3 {}
940unsafe impl Std140ArrayElement for dvec3 {}
941
942impl Index<usize> for dvec3 {
943 type Output = f64;
944
945 fn index(&self, index: usize) -> &Self::Output {
946 match index {
947 0 => &self.0,
948 1 => &self.1,
949 2 => &self.2,
950 _ => panic!("Index out of bounds"),
951 }
952 }
953}
954
955impl IndexMut<usize> for dvec3 {
956 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
957 match index {
958 0 => &mut self.0,
959 1 => &mut self.1,
960 2 => &mut self.2,
961 _ => panic!("Index out of bounds"),
962 }
963 }
964}
965
966#[repr(C, align(32))]
974#[derive(Clone, Copy, PartialEq, Debug)]
975pub struct dvec4(pub f64, pub f64, pub f64, pub f64);
976
977impl dvec4 {
978 pub fn zero() -> Self {
980 dvec4(0.0, 0.0, 0.0, 0.0)
981 }
982}
983
984unsafe impl ReprStd140 for dvec4 {}
985unsafe impl Std140ArrayElement for dvec4 {}
986
987impl Index<usize> for dvec4 {
988 type Output = f64;
989
990 fn index(&self, index: usize) -> &Self::Output {
991 match index {
992 0 => &self.0,
993 1 => &self.1,
994 2 => &self.2,
995 3 => &self.3,
996 _ => panic!("Index out of bounds"),
997 }
998 }
999}
1000
1001impl IndexMut<usize> for dvec4 {
1002 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1003 match index {
1004 0 => &mut self.0,
1005 1 => &mut self.1,
1006 2 => &mut self.2,
1007 3 => &mut self.3,
1008 _ => panic!("Index out of bounds"),
1009 }
1010 }
1011}
1012
1013#[derive(Clone, Copy, PartialEq)]
1024pub struct mat2x2 {
1025 columns: array<vec2, 2>,
1026}
1027
1028impl mat2x2 {
1029 pub fn zero() -> Self {
1031 mat2x2(vec2::zero(), vec2::zero())
1032 }
1033}
1034
1035pub fn mat2x2(c0: vec2, c1: vec2) -> mat2x2 {
1041 mat2x2 {
1042 columns: array![c0, c1],
1043 }
1044}
1045
1046unsafe impl ReprStd140 for mat2x2 {}
1047unsafe impl Std140ArrayElement for mat2x2 {}
1048
1049impl Deref for mat2x2 {
1050 type Target = array<vec2, 2>;
1051
1052 fn deref(&self) -> &Self::Target {
1053 &self.columns
1054 }
1055}
1056
1057impl DerefMut for mat2x2 {
1058 fn deref_mut(&mut self) -> &mut Self::Target {
1059 &mut self.columns
1060 }
1061}
1062
1063impl fmt::Debug for mat2x2 {
1064 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1065 f.write_fmt(format_args!("mat2x2{:?}", &self.columns))
1066 }
1067}
1068
1069#[derive(Clone, Copy, PartialEq)]
1080pub struct mat2x3 {
1081 columns: array<vec3, 2>,
1082}
1083
1084impl mat2x3 {
1085 pub fn zero() -> Self {
1087 mat2x3(vec3::zero(), vec3::zero())
1088 }
1089}
1090
1091pub fn mat2x3(c0: vec3, c1: vec3) -> mat2x3 {
1097 mat2x3 {
1098 columns: array![c0, c1],
1099 }
1100}
1101
1102unsafe impl ReprStd140 for mat2x3 {}
1103unsafe impl Std140ArrayElement for mat2x3 {}
1104
1105impl Deref for mat2x3 {
1106 type Target = array<vec3, 2>;
1107
1108 fn deref(&self) -> &Self::Target {
1109 &self.columns
1110 }
1111}
1112
1113impl DerefMut for mat2x3 {
1114 fn deref_mut(&mut self) -> &mut Self::Target {
1115 &mut self.columns
1116 }
1117}
1118
1119impl fmt::Debug for mat2x3 {
1120 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1121 f.write_fmt(format_args!("mat2x3{:?}", &self.columns))
1122 }
1123}
1124
1125#[derive(Clone, Copy, PartialEq)]
1136pub struct mat2x4 {
1137 columns: array<vec4, 2>,
1138}
1139
1140impl mat2x4 {
1141 pub fn zero() -> Self {
1143 mat2x4(vec4::zero(), vec4::zero())
1144 }
1145}
1146
1147pub fn mat2x4(c0: vec4, c1: vec4) -> mat2x4 {
1153 mat2x4 {
1154 columns: array![c0, c1],
1155 }
1156}
1157
1158unsafe impl ReprStd140 for mat2x4 {}
1159unsafe impl Std140ArrayElement for mat2x4 {}
1160
1161impl Deref for mat2x4 {
1162 type Target = array<vec4, 2>;
1163
1164 fn deref(&self) -> &Self::Target {
1165 &self.columns
1166 }
1167}
1168
1169impl DerefMut for mat2x4 {
1170 fn deref_mut(&mut self) -> &mut Self::Target {
1171 &mut self.columns
1172 }
1173}
1174
1175impl fmt::Debug for mat2x4 {
1176 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1177 f.write_fmt(format_args!("mat2x4{:?}", &self.columns))
1178 }
1179}
1180
1181#[derive(Clone, Copy, PartialEq)]
1193pub struct mat3x2 {
1194 columns: array<vec2, 3>,
1195}
1196
1197impl mat3x2 {
1198 pub fn zero() -> Self {
1200 mat3x2(vec2::zero(), vec2::zero(), vec2::zero())
1201 }
1202}
1203
1204pub fn mat3x2(c0: vec2, c1: vec2, c2: vec2) -> mat3x2 {
1210 mat3x2 {
1211 columns: array![c0, c1, c2],
1212 }
1213}
1214
1215unsafe impl ReprStd140 for mat3x2 {}
1216unsafe impl Std140ArrayElement for mat3x2 {}
1217
1218impl Deref for mat3x2 {
1219 type Target = array<vec2, 3>;
1220
1221 fn deref(&self) -> &Self::Target {
1222 &self.columns
1223 }
1224}
1225
1226impl DerefMut for mat3x2 {
1227 fn deref_mut(&mut self) -> &mut Self::Target {
1228 &mut self.columns
1229 }
1230}
1231
1232impl fmt::Debug for mat3x2 {
1233 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1234 f.write_fmt(format_args!("mat3x2{:?}", &self.columns))
1235 }
1236}
1237
1238#[derive(Clone, Copy, PartialEq)]
1250pub struct mat3x3 {
1251 columns: array<vec3, 3>,
1252}
1253
1254impl mat3x3 {
1255 pub fn zero() -> Self {
1257 mat3x3(vec3::zero(), vec3::zero(), vec3::zero())
1258 }
1259}
1260
1261pub fn mat3x3(c0: vec3, c1: vec3, c2: vec3) -> mat3x3 {
1267 mat3x3 {
1268 columns: array![c0, c1, c2],
1269 }
1270}
1271
1272unsafe impl ReprStd140 for mat3x3 {}
1273unsafe impl Std140ArrayElement for mat3x3 {}
1274
1275impl Deref for mat3x3 {
1276 type Target = array<vec3, 3>;
1277
1278 fn deref(&self) -> &Self::Target {
1279 &self.columns
1280 }
1281}
1282
1283impl DerefMut for mat3x3 {
1284 fn deref_mut(&mut self) -> &mut Self::Target {
1285 &mut self.columns
1286 }
1287}
1288
1289impl fmt::Debug for mat3x3 {
1290 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1291 f.write_fmt(format_args!("mat3x3{:?}", &self.columns))
1292 }
1293}
1294
1295#[derive(Clone, Copy, PartialEq)]
1307pub struct mat3x4 {
1308 columns: array<vec4, 3>,
1309}
1310
1311impl mat3x4 {
1312 pub fn zero() -> Self {
1314 mat3x4(vec4::zero(), vec4::zero(), vec4::zero())
1315 }
1316}
1317
1318pub fn mat3x4(c0: vec4, c1: vec4, c2: vec4) -> mat3x4 {
1324 mat3x4 {
1325 columns: array![c0, c1, c2],
1326 }
1327}
1328
1329unsafe impl ReprStd140 for mat3x4 {}
1330unsafe impl Std140ArrayElement for mat3x4 {}
1331
1332impl Deref for mat3x4 {
1333 type Target = array<vec4, 3>;
1334
1335 fn deref(&self) -> &Self::Target {
1336 &self.columns
1337 }
1338}
1339
1340impl DerefMut for mat3x4 {
1341 fn deref_mut(&mut self) -> &mut Self::Target {
1342 &mut self.columns
1343 }
1344}
1345
1346impl fmt::Debug for mat3x4 {
1347 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1348 f.write_fmt(format_args!("mat3x4{:?}", &self.columns))
1349 }
1350}
1351
1352#[derive(Clone, Copy, PartialEq)]
1365pub struct mat4x2 {
1366 columns: array<vec2, 4>,
1367}
1368
1369impl mat4x2 {
1370 pub fn zero() -> Self {
1372 mat4x2(vec2::zero(), vec2::zero(), vec2::zero(), vec2::zero())
1373 }
1374}
1375
1376pub fn mat4x2(c0: vec2, c1: vec2, c2: vec2, c3: vec2) -> mat4x2 {
1382 mat4x2 {
1383 columns: array![c0, c1, c2, c3],
1384 }
1385}
1386
1387unsafe impl ReprStd140 for mat4x2 {}
1388unsafe impl Std140ArrayElement for mat4x2 {}
1389
1390impl Deref for mat4x2 {
1391 type Target = array<vec2, 4>;
1392
1393 fn deref(&self) -> &Self::Target {
1394 &self.columns
1395 }
1396}
1397
1398impl DerefMut for mat4x2 {
1399 fn deref_mut(&mut self) -> &mut Self::Target {
1400 &mut self.columns
1401 }
1402}
1403
1404impl fmt::Debug for mat4x2 {
1405 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1406 f.write_fmt(format_args!("mat4x2{:?}", &self.columns))
1407 }
1408}
1409
1410#[derive(Clone, Copy, PartialEq)]
1423pub struct mat4x3 {
1424 columns: array<vec3, 4>,
1425}
1426
1427impl mat4x3 {
1428 pub fn zero() -> Self {
1430 mat4x3(vec3::zero(), vec3::zero(), vec3::zero(), vec3::zero())
1431 }
1432}
1433
1434pub fn mat4x3(c0: vec3, c1: vec3, c2: vec3, c3: vec3) -> mat4x3 {
1440 mat4x3 {
1441 columns: array![c0, c1, c2, c3],
1442 }
1443}
1444
1445unsafe impl ReprStd140 for mat4x3 {}
1446unsafe impl Std140ArrayElement for mat4x3 {}
1447
1448impl Deref for mat4x3 {
1449 type Target = array<vec3, 4>;
1450
1451 fn deref(&self) -> &Self::Target {
1452 &self.columns
1453 }
1454}
1455
1456impl DerefMut for mat4x3 {
1457 fn deref_mut(&mut self) -> &mut Self::Target {
1458 &mut self.columns
1459 }
1460}
1461
1462impl fmt::Debug for mat4x3 {
1463 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1464 f.write_fmt(format_args!("mat4x3{:?}", &self.columns))
1465 }
1466}
1467
1468#[derive(Clone, Copy, PartialEq)]
1481pub struct mat4x4 {
1482 columns: array<vec4, 4>,
1483}
1484
1485impl mat4x4 {
1486 pub fn zero() -> Self {
1488 mat4x4(vec4::zero(), vec4::zero(), vec4::zero(), vec4::zero())
1489 }
1490}
1491
1492pub fn mat4x4(c0: vec4, c1: vec4, c2: vec4, c3: vec4) -> mat4x4 {
1498 mat4x4 {
1499 columns: array![c0, c1, c2, c3],
1500 }
1501}
1502
1503unsafe impl ReprStd140 for mat4x4 {}
1504unsafe impl Std140ArrayElement for mat4x4 {}
1505
1506impl Deref for mat4x4 {
1507 type Target = array<vec4, 4>;
1508
1509 fn deref(&self) -> &Self::Target {
1510 &self.columns
1511 }
1512}
1513
1514impl DerefMut for mat4x4 {
1515 fn deref_mut(&mut self) -> &mut Self::Target {
1516 &mut self.columns
1517 }
1518}
1519
1520impl fmt::Debug for mat4x4 {
1521 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1522 f.write_fmt(format_args!("mat4x4{:?}", &self.columns))
1523 }
1524}
1525
1526#[derive(Clone, Copy, PartialEq)]
1537pub struct dmat2x2 {
1538 columns: array<dvec2, 2>,
1539}
1540
1541impl dmat2x2 {
1542 pub fn zero() -> Self {
1544 dmat2x2(dvec2::zero(), dvec2::zero())
1545 }
1546}
1547
1548pub fn dmat2x2(c0: dvec2, c1: dvec2) -> dmat2x2 {
1554 dmat2x2 {
1555 columns: array![c0, c1],
1556 }
1557}
1558
1559unsafe impl ReprStd140 for dmat2x2 {}
1560unsafe impl Std140ArrayElement for dmat2x2 {}
1561
1562impl Deref for dmat2x2 {
1563 type Target = array<dvec2, 2>;
1564
1565 fn deref(&self) -> &Self::Target {
1566 &self.columns
1567 }
1568}
1569
1570impl DerefMut for dmat2x2 {
1571 fn deref_mut(&mut self) -> &mut Self::Target {
1572 &mut self.columns
1573 }
1574}
1575
1576impl fmt::Debug for dmat2x2 {
1577 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1578 f.write_fmt(format_args!("dmat2x2{:?}", &self.columns))
1579 }
1580}
1581
1582#[derive(Clone, Copy, PartialEq)]
1593pub struct dmat2x3 {
1594 columns: array<dvec3, 2>,
1595}
1596
1597impl dmat2x3 {
1598 pub fn zero() -> Self {
1600 dmat2x3(dvec3::zero(), dvec3::zero())
1601 }
1602}
1603
1604pub fn dmat2x3(c0: dvec3, c1: dvec3) -> dmat2x3 {
1610 dmat2x3 {
1611 columns: array![c0, c1],
1612 }
1613}
1614
1615unsafe impl ReprStd140 for dmat2x3 {}
1616unsafe impl Std140ArrayElement for dmat2x3 {}
1617
1618impl Deref for dmat2x3 {
1619 type Target = array<dvec3, 2>;
1620
1621 fn deref(&self) -> &Self::Target {
1622 &self.columns
1623 }
1624}
1625
1626impl DerefMut for dmat2x3 {
1627 fn deref_mut(&mut self) -> &mut Self::Target {
1628 &mut self.columns
1629 }
1630}
1631
1632impl fmt::Debug for dmat2x3 {
1633 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1634 f.write_fmt(format_args!("dmat2x3{:?}", &self.columns))
1635 }
1636}
1637
1638#[derive(Clone, Copy, PartialEq)]
1649pub struct dmat2x4 {
1650 columns: array<dvec4, 2>,
1651}
1652
1653impl dmat2x4 {
1654 pub fn zero() -> Self {
1656 dmat2x4(dvec4::zero(), dvec4::zero())
1657 }
1658}
1659
1660pub fn dmat2x4(c0: dvec4, c1: dvec4) -> dmat2x4 {
1666 dmat2x4 {
1667 columns: array![c0, c1],
1668 }
1669}
1670
1671unsafe impl ReprStd140 for dmat2x4 {}
1672unsafe impl Std140ArrayElement for dmat2x4 {}
1673
1674impl Deref for dmat2x4 {
1675 type Target = array<dvec4, 2>;
1676
1677 fn deref(&self) -> &Self::Target {
1678 &self.columns
1679 }
1680}
1681
1682impl DerefMut for dmat2x4 {
1683 fn deref_mut(&mut self) -> &mut Self::Target {
1684 &mut self.columns
1685 }
1686}
1687
1688impl fmt::Debug for dmat2x4 {
1689 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1690 f.write_fmt(format_args!("dmat2x4{:?}", &self.columns))
1691 }
1692}
1693
1694#[derive(Clone, Copy, PartialEq)]
1706pub struct dmat3x2 {
1707 columns: array<dvec2, 3>,
1708}
1709
1710impl dmat3x2 {
1711 pub fn zero() -> Self {
1713 dmat3x2(dvec2::zero(), dvec2::zero(), dvec2::zero())
1714 }
1715}
1716
1717pub fn dmat3x2(c0: dvec2, c1: dvec2, c2: dvec2) -> dmat3x2 {
1723 dmat3x2 {
1724 columns: array![c0, c1, c2],
1725 }
1726}
1727
1728unsafe impl ReprStd140 for dmat3x2 {}
1729unsafe impl Std140ArrayElement for dmat3x2 {}
1730
1731impl Deref for dmat3x2 {
1732 type Target = array<dvec2, 3>;
1733
1734 fn deref(&self) -> &Self::Target {
1735 &self.columns
1736 }
1737}
1738
1739impl DerefMut for dmat3x2 {
1740 fn deref_mut(&mut self) -> &mut Self::Target {
1741 &mut self.columns
1742 }
1743}
1744
1745impl fmt::Debug for dmat3x2 {
1746 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1747 f.write_fmt(format_args!("dmat3x2{:?}", &self.columns))
1748 }
1749}
1750
1751#[derive(Clone, Copy, PartialEq)]
1763pub struct dmat3x3 {
1764 columns: array<dvec3, 3>,
1765}
1766
1767impl dmat3x3 {
1768 pub fn zero() -> Self {
1770 dmat3x3(dvec3::zero(), dvec3::zero(), dvec3::zero())
1771 }
1772}
1773
1774pub fn dmat3x3(c0: dvec3, c1: dvec3, c2: dvec3) -> dmat3x3 {
1780 dmat3x3 {
1781 columns: array![c0, c1, c2],
1782 }
1783}
1784
1785unsafe impl ReprStd140 for dmat3x3 {}
1786unsafe impl Std140ArrayElement for dmat3x3 {}
1787
1788impl Deref for dmat3x3 {
1789 type Target = array<dvec3, 3>;
1790
1791 fn deref(&self) -> &Self::Target {
1792 &self.columns
1793 }
1794}
1795
1796impl DerefMut for dmat3x3 {
1797 fn deref_mut(&mut self) -> &mut Self::Target {
1798 &mut self.columns
1799 }
1800}
1801
1802impl fmt::Debug for dmat3x3 {
1803 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1804 f.write_fmt(format_args!("dmat3x3{:?}", &self.columns))
1805 }
1806}
1807
1808#[derive(Clone, Copy, PartialEq)]
1820pub struct dmat3x4 {
1821 columns: array<dvec4, 3>,
1822}
1823
1824impl dmat3x4 {
1825 pub fn zero() -> Self {
1827 dmat3x4(dvec4::zero(), dvec4::zero(), dvec4::zero())
1828 }
1829}
1830
1831pub fn dmat3x4(c0: dvec4, c1: dvec4, c2: dvec4) -> dmat3x4 {
1837 dmat3x4 {
1838 columns: array![c0, c1, c2],
1839 }
1840}
1841
1842unsafe impl ReprStd140 for dmat3x4 {}
1843unsafe impl Std140ArrayElement for dmat3x4 {}
1844
1845impl Deref for dmat3x4 {
1846 type Target = array<dvec4, 3>;
1847
1848 fn deref(&self) -> &Self::Target {
1849 &self.columns
1850 }
1851}
1852
1853impl DerefMut for dmat3x4 {
1854 fn deref_mut(&mut self) -> &mut Self::Target {
1855 &mut self.columns
1856 }
1857}
1858
1859impl fmt::Debug for dmat3x4 {
1860 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1861 f.write_fmt(format_args!("dmat3x4{:?}", &self.columns))
1862 }
1863}
1864
1865#[derive(Clone, Copy, PartialEq)]
1878pub struct dmat4x2 {
1879 columns: array<dvec2, 4>,
1880}
1881
1882impl dmat4x2 {
1883 pub fn zero() -> Self {
1885 dmat4x2(dvec2::zero(), dvec2::zero(), dvec2::zero(), dvec2::zero())
1886 }
1887}
1888
1889pub fn dmat4x2(c0: dvec2, c1: dvec2, c2: dvec2, c3: dvec2) -> dmat4x2 {
1895 dmat4x2 {
1896 columns: array![c0, c1, c2, c3],
1897 }
1898}
1899
1900unsafe impl ReprStd140 for dmat4x2 {}
1901unsafe impl Std140ArrayElement for dmat4x2 {}
1902
1903impl Deref for dmat4x2 {
1904 type Target = array<dvec2, 4>;
1905
1906 fn deref(&self) -> &Self::Target {
1907 &self.columns
1908 }
1909}
1910
1911impl DerefMut for dmat4x2 {
1912 fn deref_mut(&mut self) -> &mut Self::Target {
1913 &mut self.columns
1914 }
1915}
1916
1917impl fmt::Debug for dmat4x2 {
1918 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1919 f.write_fmt(format_args!("dmat4x2{:?}", &self.columns))
1920 }
1921}
1922
1923#[derive(Clone, Copy, PartialEq)]
1936pub struct dmat4x3 {
1937 columns: array<dvec3, 4>,
1938}
1939
1940impl dmat4x3 {
1941 pub fn zero() -> Self {
1943 dmat4x3(dvec3::zero(), dvec3::zero(), dvec3::zero(), dvec3::zero())
1944 }
1945}
1946
1947pub fn dmat4x3(c0: dvec3, c1: dvec3, c2: dvec3, c3: dvec3) -> dmat4x3 {
1953 dmat4x3 {
1954 columns: array![c0, c1, c2, c3],
1955 }
1956}
1957
1958unsafe impl ReprStd140 for dmat4x3 {}
1959unsafe impl Std140ArrayElement for dmat4x3 {}
1960
1961impl Deref for dmat4x3 {
1962 type Target = array<dvec3, 4>;
1963
1964 fn deref(&self) -> &Self::Target {
1965 &self.columns
1966 }
1967}
1968
1969impl DerefMut for dmat4x3 {
1970 fn deref_mut(&mut self) -> &mut Self::Target {
1971 &mut self.columns
1972 }
1973}
1974
1975impl fmt::Debug for dmat4x3 {
1976 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1977 f.write_fmt(format_args!("dmat4x3{:?}", &self.columns))
1978 }
1979}
1980
1981#[derive(Clone, Copy, PartialEq)]
1994pub struct dmat4x4 {
1995 columns: array<dvec4, 4>,
1996}
1997
1998impl dmat4x4 {
1999 pub fn zero() -> Self {
2001 dmat4x4(dvec4::zero(), dvec4::zero(), dvec4::zero(), dvec4::zero())
2002 }
2003}
2004
2005pub fn dmat4x4(c0: dvec4, c1: dvec4, c2: dvec4, c3: dvec4) -> dmat4x4 {
2011 dmat4x4 {
2012 columns: array![c0, c1, c2, c3],
2013 }
2014}
2015
2016unsafe impl ReprStd140 for dmat4x4 {}
2017unsafe impl Std140ArrayElement for dmat4x4 {}
2018
2019impl Deref for dmat4x4 {
2020 type Target = array<dvec4, 4>;
2021
2022 fn deref(&self) -> &Self::Target {
2023 &self.columns
2024 }
2025}
2026
2027impl DerefMut for dmat4x4 {
2028 fn deref_mut(&mut self) -> &mut Self::Target {
2029 &mut self.columns
2030 }
2031}
2032
2033impl fmt::Debug for dmat4x4 {
2034 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2035 f.write_fmt(format_args!("dmat4x4{:?}", &self.columns))
2036 }
2037}