Merge branch 'master' into vec2_mat2

This commit is contained in:
Recep Aslantas
2020-02-23 13:10:36 +03:00
75 changed files with 8194 additions and 1305 deletions

View File

@@ -10,40 +10,71 @@
#include "types.h"
/*
* Anonymous structs are available since C11, but we'd like to be compatible
* with C99 and C89 too. So let's figure out if we should be using them or not.
* It's simply a convenience feature, you can e.g. build the library with
* anonymous structs and your application without them and they'll still be
* compatible, cglm doesn't use the anonymous structs internally.
*/
#ifndef CGLM_USE_ANONYMOUS_STRUCT
/* If the user doesn't explicitly specify if they want anonymous structs or
* not, then we'll try to intuit an appropriate choice. */
# if defined(CGLM_NO_ANONYMOUS_STRUCT)
/* The user has defined CGLM_NO_ANONYMOUS_STRUCT. This used to be the
* only #define governing the use of anonymous structs, so for backward
* compatibility, we still honor that choice and disable them. */
# define CGLM_USE_ANONYMOUS_STRUCT 0
# elif __STDC_VERSION__ >= 20112L || defined(_MSVC_VER)
/* We're compiling for C11 or this is the MSVC compiler. In either
* case, anonymous structs are available, so use them. */
# define CGLM_USE_ANONYMOUS_STRUCT 1
# elif defined(_MSC_VER) && (_MSC_VER >= 1900) /* Visual Studio 2015 */
/* We can support anonymous structs
* since Visual Studio 2015 or 2017 (1910) maybe? */
# define CGLM_USE_ANONYMOUS_STRUCT 1
# else
/* Otherwise, we're presumably building for C99 or C89 and can't rely
* on anonymous structs being available. Turn them off. */
# define CGLM_USE_ANONYMOUS_STRUCT 0
# endif
#endif
typedef union vec2s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
vec2 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float x;
float y;
};
#endif
vec2 raw;
} vec2s;
typedef union vec3s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
vec3 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float x;
float y;
float z;
};
#endif
vec3 raw;
} vec3s;
typedef union ivec3s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
ivec3 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
int x;
int y;
int z;
};
#endif
ivec3 raw;
} ivec3s;
typedef union CGLM_ALIGN_IF(16) vec4s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
vec4 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float x;
float y;
@@ -51,11 +82,11 @@ typedef union CGLM_ALIGN_IF(16) vec4s {
float w;
};
#endif
vec4 raw;
} vec4s;
typedef union CGLM_ALIGN_IF(16) versors {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
vec4 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float x;
float y;
@@ -68,34 +99,35 @@ typedef union CGLM_ALIGN_IF(16) versors {
float real;
};
#endif
vec4 raw;
} versors;
typedef union mat2s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
mat2 raw;
vec2s col[2];
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float m00, m01;
float m10, m11;
};
#endif
vec2s col[2];
mat2 raw;
} mat2s;
typedef union mat3s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
mat3 raw;
vec3s col[3];
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float m00, m01, m02;
float m10, m11, m12;
float m20, m21, m22;
};
#endif
vec3s col[3];
mat3 raw;
} mat3s;
typedef union CGLM_ALIGN_MAT mat4s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
mat4 raw;
vec4s col[4];
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
float m00, m01, m02, m03;
float m10, m11, m12, m13;
@@ -103,8 +135,6 @@ typedef union CGLM_ALIGN_MAT mat4s {
float m30, m31, m32, m33;
};
#endif
vec4s col[4];
mat4 raw;
} mat4s;
#endif /* cglm_types_struct_h */