From 5cd1a4ab44b9608ce0790359b860da007e17dae7 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Thu, 6 Jan 2022 18:01:35 +0300 Subject: [PATCH 1/2] add missing ivec types --- include/cglm/types-struct.h | 22 ++++++++++++++++++++++ include/cglm/types.h | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/cglm/types-struct.h b/include/cglm/types-struct.h index f211e0a..eec8d8e 100644 --- a/include/cglm/types-struct.h +++ b/include/cglm/types-struct.h @@ -61,6 +61,16 @@ typedef union vec3s { #endif } vec3s; +typedef union ivec2s { + ivec2 raw; +#if CGLM_USE_ANONYMOUS_STRUCT + struct { + int x; + int y; + }; +#endif +} ivec2s; + typedef union ivec3s { ivec3 raw; #if CGLM_USE_ANONYMOUS_STRUCT @@ -72,6 +82,18 @@ typedef union ivec3s { #endif } ivec3s; +typedef union ivec4s { + ivec4 raw; +#if CGLM_USE_ANONYMOUS_STRUCT + struct { + int x; + int y; + int z; + int w; + }; +#endif +} ivec4s; + typedef union CGLM_ALIGN_IF(16) vec4s { vec4 raw; #if CGLM_USE_ANONYMOUS_STRUCT diff --git a/include/cglm/types.h b/include/cglm/types.h index 80463a2..a671c5a 100644 --- a/include/cglm/types.h +++ b/include/cglm/types.h @@ -42,9 +42,12 @@ #define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ ((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type))) +typedef int ivec2[2]; +typedef int ivec3[3]; +typedef int ivec4[4]; + typedef float vec2[2]; typedef float vec3[3]; -typedef int ivec3[3]; typedef CGLM_ALIGN_IF(16) float vec4[4]; typedef vec4 versor; /* |x, y, z, w| -> w is the last */ typedef vec3 mat3[3]; From 3a141b7cc8ec714ce8f4a42f40169c7eb2ac44ff Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Thu, 6 Jan 2022 18:12:46 +0300 Subject: [PATCH 2/2] extend unions for struct api --- include/cglm/types-struct.h | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/cglm/types-struct.h b/include/cglm/types-struct.h index eec8d8e..1d91097 100644 --- a/include/cglm/types-struct.h +++ b/include/cglm/types-struct.h @@ -47,6 +47,21 @@ typedef union vec2s { float x; float y; }; + + struct { + float r; + float i; + }; + + struct { + float u; + float v; + }; + + struct { + float s; + float t; + }; #endif } vec2s; @@ -58,6 +73,12 @@ typedef union vec3s { float y; float z; }; + + struct { + float r; + float g; + float b; + }; #endif } vec3s; @@ -68,6 +89,21 @@ typedef union ivec2s { int x; int y; }; + + struct { + int r; + int i; + }; + + struct { + int u; + int v; + }; + + struct { + int s; + int t; + }; #endif } ivec2s; @@ -79,6 +115,12 @@ typedef union ivec3s { int y; int z; }; + + struct { + int r; + int g; + int b; + }; #endif } ivec3s; @@ -91,6 +133,13 @@ typedef union ivec4s { int z; int w; }; + + struct { + int r; + int g; + int b; + int a; + }; #endif } ivec4s; @@ -103,6 +152,13 @@ typedef union CGLM_ALIGN_IF(16) vec4s { float z; float w; }; + + struct { + float r; + float g; + float b; + float a; + }; #endif } vec4s;