Initial implementation of struct type vec4s

This commit is contained in:
acoto87
2019-04-03 22:25:49 -06:00
parent 674e05213a
commit c25469829a
8 changed files with 178 additions and 29 deletions

20
include/cglm/cglms.h Normal file
View File

@@ -0,0 +1,20 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_structs_h
#define cglm_structs_h
#ifdef __cplusplus
extern "C" {
#endif
#include "cglm.h"
#include "structs/vec4.h"
#ifdef __cplusplus
}
#endif
#endif /* cglm_structs_h */

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_vec4s_ext_h
#define cglm_vec4s_ext_h
#include "common.h"
#include "vec3-ext.h"
#include <stdbool.h>
#include <math.h>
#include <float.h>
CGLM_INLINE
vec4s
glms_vec4_broadcast(float val, vec4 d)
{
vec4s r;
glm_vec4_broadcast(val, r.raw);
return r;
}
CGLM_INLINE
bool
glms_vec4_eq(vec4s v, float val)
{
return glm_vec4_eq(v.raw, val);
}
CGLM_INLINE
bool
glms_vec4_eq_eps(vec4 v, float val)
{
return glm_vec4_eq_eps(v.raw, val);
}
CGLM_INLINE
bool
glms_vec4_eq_all(vec4s v)
{
return glm_vec4_eq_all(v.raw);
}
CGLM_INLINE
bool
glms_vec4_eqv(vec4s a, vec4s b)
{
return glm_vec4_eqv(a.raw, b.raw);
}
CGLM_INLINE
bool
glms_vec4_eqv_eps(vec4s a, vec4s b)
{
return glm_vec4_eqv_eps(a.raw, b.raw);
}
CGLM_INLINE
float
glms_vec4_max(vec4s v)
{
return glm_vec4_max(v.raw);
}
CGLM_INLINE
float
glms_vec4_min(vec4s v)
{
return glm_vec4_min(v.raw);
}
CGLM_INLINE
bool
glms_vec4_isnan(vec4s v)
{
return glm_vec4_isnan(v.raw);
}
CGLM_INLINE
bool
glms_vec4_isinf(vec4s v)
{
return glm_vec4_isinf(v.raw);
}
CGLM_INLINE
bool
glms_vec4_isvalid(vec4s v)
{
return glm_vec4_isvalid(v.raw);
}
CGLM_INLINE
vec4s
glms_vec4_sign(vec4s v)
{
vec4s r;
glm_vec4_sign(v.raw, r.raw);
return r;
}
CGLM_INLINE
vec4s
glms_vec4_sqrt(vec4s v)
{
vec4s r;
glm_vec4_sqrt(v.raw, r.raw);
return r;
}
#endif /* cglm_vec4s_ext_h */

View File

@@ -8,9 +8,11 @@
#ifndef cglm_vec4s_h
#define cglm_vec4s_h
#include "common.h"
#include "vec4-ext.h"
#include "util.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
#define GLMS_VEC4_ONE_INIT {1.0f, 1.0f, 1.0f, 1.0f}
#define GLMS_VEC4_BLACK_INIT {0.0f, 0.0f, 0.0f, 1.0f}
@@ -92,7 +94,7 @@ vec4s
glms_vec4_adds(vec4s v, float s)
{
vec4s r;
glm_vec4_adds(v.raw s, r.raw);
glm_vec4_adds(v.raw, s, r.raw);
return r;
}
@@ -226,7 +228,7 @@ vec4s
glms_vec4_inv(vec4s v)
{
glm_vec4_inv(v.raw);
return r;
return v;
}
CGLM_INLINE
@@ -279,4 +281,7 @@ glms_vec4_lerp(vec4s from, vec4s to, float t)
return r;
}
#ifdef __cplusplus
}
#endif
#endif /* cglm_vec4s_h */

View File

@@ -47,17 +47,7 @@ typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
#endif
// struct types
typedef union CGLM_ALIGN_IF(8) vec2s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
struct {
float x;
float y;
};
#endif
vec2 raw;
} vec2s;
typedef union CGLM_ALIGN_IF(8) vec3s {
typedef union CGLM_ALIGN_IF(16) vec3s {
#ifndef CGLM_NO_ANONYMOUS_STRUCT
struct {
float x;
@@ -68,17 +58,6 @@ typedef union CGLM_ALIGN_IF(8) vec3s {
vec3 raw;
} vec3s;
typedef union CGLM_ALIGN_IF(8) ivec3s {
#ifndef CGLM_NO_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
struct {