50#define N_BIT(x) (1 << x)
51template <
class MASK,
class BITS>
61template <
class MASK,
class BITS>
65 return MASK(
uint(mask) & ~
uint(bit));
68#define N_ARGB(a,r,g,b) ((uint)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
69#define N_RGBA(r,g,b,a) N_ARGB(a,r,g,b)
70#define N_XRGB(r,g,b) N_ARGB(0xff,r,g,b)
71#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))
77template <
class FLAGS,
class BITS>
79AllBits(
const FLAGS flags,
const BITS bits)
81 return (flags & bits) == bits;
88template <
class FLAGS,
class BITS>
90AnyBits(
const FLAGS flags,
const BITS bits)
92 return (flags & bits) != (FLAGS)0;
98template <
class FLAGS,
class BITS>
102 return (flags & bits) == flags;
106#define BITS_TO_BYTES(x) (((x)+7)>>3)
107#define BYTES_TO_BITS(x) ((x)<<3)
109#if (__OSX__ || __linux__)
110inline ushort _byteswap_ushort(
ushort x) {
return ((x>>8) | (x<<8)); }
111inline ulong _byteswap_ulong(
ulong x) {
return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
112inline 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)))); }
116typedef unsigned char byte;
119#define n_stricmp stricmp
120#define n_snprintf StringCchPrintf
121#elif (__OSX__ || __APPLE__ || __linux__ )
122#define n_stricmp strcasecmp
123#define n_snprintf sprintf
125#error "Unsupported platform!"
131#define ThreadLocal __declspec(thread)
133#define ThreadLocal __thread
134#if (__OSX__ || __APPLE__)
140#error "Unsupported platform!"
143#define lengthof(x) (sizeof(x) / sizeof(*x))
145#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:79
constexpr MASK UnsetBits(const MASK mask, const BITS bit)
Definition types.h:63
static const int InvalidIndex
Definition types.h:45
ptrdiff_t ptrdiff
Definition types.h:37
constexpr bool OnlyBits(const FLAGS flags, const BITS bits)
Definition types.h:100
unsigned char ubyte
Definition types.h:34
ptrdiff PtrDiff
Definition types.h:44
uintptr_t uintptr
Definition types.h:36
unsigned char uchar
Definition types.h:33
unsigned long ulong
Definition types.h:30
constexpr bool AnyBits(const FLAGS flags, const BITS bits)
Check if any bits are set in flags.
Definition types.h:90
int SizeT
Definition types.h:40
int64_t Size64T
Definition types.h:42
unsigned int uint
Definition types.h:31
uintptr PtrT
Definition types.h:43
constexpr MASK SetBits(const MASK mask, const BITS bit)
Definition types.h:53
unsigned short ushort
Definition types.h:32
int64_t Index64T
Definition types.h:41
int IndexT
Definition types.h:39