59#define N_BIT(x) (1 << x)
60template <
class MASK,
class BITS>
70template <
class MASK,
class BITS>
74 return MASK(
uint(mask) & ~
uint(bit));
77#define N_ARGB(a,r,g,b) ((uint)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
78#define N_RGBA(r,g,b,a) N_ARGB(a,r,g,b)
79#define N_XRGB(r,g,b) N_ARGB(0xff,r,g,b)
80#define N_COLORVALUE(r,g,b,a) N_RGBA((uint)((r)*255.f),(uint)((g)*255.f),(uint)((b)*255.f),(uint)((a)*255.f))
86template <
class FLAGS,
class BITS>
88AllBits(
const FLAGS flags,
const BITS bits)
90 return (flags & bits) == bits;
97template <
class FLAGS,
class BITS>
99AnyBits(
const FLAGS flags,
const BITS bits)
101 return (flags & bits) != (FLAGS)0;
107template <
class FLAGS,
class BITS>
111 return (flags & bits) == flags;
115#define BITS_TO_BYTES(x) (((x)+7)>>3)
116#define BYTES_TO_BITS(x) ((x)<<3)
118#if (__OSX__ || __linux__)
119inline ushort _byteswap_ushort(
ushort x) {
return ((x>>8) | (x<<8)); }
120inline ulong _byteswap_ulong(
ulong x) {
return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
121inline unsigned long long _byteswap_uint64(
unsigned long long x) {
return ((((
unsigned long long)_byteswap_ulong((
ulong)(x & 0xffffffff))) << 32) | ((
unsigned long long)_byteswap_ulong((
ulong)(x >> 32)))); }
125typedef unsigned char byte;
128#define n_stricmp stricmp
129#define n_snprintf StringCchPrintf
130#elif (__OSX__ || __APPLE__ || __linux__ )
131#define n_stricmp strcasecmp
132#define n_snprintf sprintf
134#error "Unsupported platform!"
140#define ThreadLocal __declspec(thread)
142#define ThreadLocal __thread
143#if (__OSX__ || __APPLE__)
149#error "Unsupported platform!"
152#define lengthof(x) (sizeof(x) / sizeof(*x))
154#define NEBULA_ALIGN16 alignas(16)
Implements a memory related functions.
constexpr bool AllBits(const FLAGS flags, const BITS bits)
Check if all bits are set in flags.
Definition types.h:88
constexpr MASK UnsetBits(const MASK mask, const BITS bit)
Definition types.h:72
uint8_t uint8
Definition types.h:42
static const int InvalidIndex
Definition types.h:54
ptrdiff_t ptrdiff
Definition types.h:46
constexpr bool OnlyBits(const FLAGS flags, const BITS bits)
Definition types.h:109
unsigned char ubyte
Definition types.h:34
ptrdiff PtrDiff
Definition types.h:53
uintptr_t uintptr
Definition types.h:45
unsigned char uchar
Definition types.h:33
unsigned long ulong
Definition types.h:30
int64_t int64
Definition types.h:37
constexpr bool AnyBits(const FLAGS flags, const BITS bits)
Check if any bits are set in flags.
Definition types.h:99
int SizeT
Definition types.h:49
int64_t Size64T
Definition types.h:51
unsigned int uint
Definition types.h:31
uintptr PtrT
Definition types.h:52
int16_t int16
Definition types.h:41
int8_t int8
Definition types.h:43
constexpr MASK SetBits(const MASK mask, const BITS bit)
Definition types.h:62
int32_t int32
Definition types.h:39
unsigned short ushort
Definition types.h:32
uint64_t uint64
Definition types.h:36
int64_t Index64T
Definition types.h:50
uint16_t uint16
Definition types.h:40
uint32_t uint32
Definition types.h:38
int IndexT
Definition types.h:48