add nil entity macros
This commit is contained in:
parent
46495d5815
commit
b5433abf22
18
src/common.h
18
src/common.h
@ -161,8 +161,9 @@ extern "C" {
|
|||||||
#define INTERNAL static
|
#define INTERNAL static
|
||||||
#define GLOBAL static
|
#define GLOBAL static
|
||||||
|
|
||||||
|
/* Storage specifiers */
|
||||||
#pragma section(".roglob", read)
|
#pragma section(".roglob", read)
|
||||||
#define READONLY __declspec(allocate(".roglob"))
|
#define READ_ONLY __declspec(allocate(".roglob"))
|
||||||
|
|
||||||
/* Markup */
|
/* Markup */
|
||||||
#define UNUSED void
|
#define UNUSED void
|
||||||
@ -238,6 +239,19 @@ extern "C" {
|
|||||||
#define CAT1(a, b) a ## b
|
#define CAT1(a, b) a ## b
|
||||||
#define CAT(a, b) CAT1(a, b)
|
#define CAT(a, b) CAT1(a, b)
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Nil structs
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
/* Declare */
|
||||||
|
#define DECLARE_NIL_STRUCT(type, function_name) \
|
||||||
|
extern READ_ONLY type CAT(__nil_struct__, function_name); \
|
||||||
|
INLINE READ_ONLY type *function_name(void) { return &CAT(__nil_struct__, function_name); }
|
||||||
|
|
||||||
|
/* Expects struct body after invocation. E.g. DEFINE_NIL_STRUCT(struct a, a_nil) { 0 } */
|
||||||
|
#define DEFINE_NIL_STRUCT(type, function_name) \
|
||||||
|
type READ_ONLY CAT(__nil_struct__, function_name)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Bit utils
|
* Bit utils
|
||||||
@ -412,12 +426,10 @@ struct v4_array {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct xform {
|
struct xform {
|
||||||
struct {
|
|
||||||
struct v2 bx; /* X basis vector (x axis) */
|
struct v2 bx; /* X basis vector (x axis) */
|
||||||
struct v2 by; /* Y basis vector (y axis)*/
|
struct v2 by; /* Y basis vector (y axis)*/
|
||||||
struct v2 og; /* Translation vector (origin) */
|
struct v2 og; /* Translation vector (origin) */
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct mat4x4 {
|
struct mat4x4 {
|
||||||
f32 e[4][4];
|
f32 e[4][4];
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
|
|
||||||
READONLY struct entity _g_entity_nil = { 0 };
|
DEFINE_NIL_STRUCT(struct entity, entity_nil) = { 0 };
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Prop
|
* Prop
|
||||||
|
|||||||
@ -96,14 +96,7 @@ struct entity {
|
|||||||
f32 camera_zoom;
|
f32 camera_zoom;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Nil entity */
|
DECLARE_NIL_STRUCT(struct entity, entity_nil)
|
||||||
|
|
||||||
extern READONLY struct entity _g_entity_nil;
|
|
||||||
|
|
||||||
INLINE READONLY struct entity *entity_nil(void)
|
|
||||||
{
|
|
||||||
return &_g_entity_nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prop */
|
/* Prop */
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user