lovr/src/util.h

26 lines
768 B
C
Raw Normal View History

2017-03-11 10:19:33 +00:00
#include "lib/vec/vec.h"
2017-01-22 02:00:32 +00:00
#include <stddef.h>
2016-09-30 06:18:51 +00:00
2017-01-26 10:20:30 +00:00
#pragma once
2016-10-04 22:05:34 +00:00
2017-01-22 02:00:32 +00:00
#define containerof(ptr, type) ((type*)((char*)(ptr) - offsetof(type, ref)))
#define LOVR_COLOR(r, g, b, a) ((a << 0) | (b << 8) | (g << 16) | (r << 24))
#define LOVR_COLOR_R(c) (c >> 24 & 0xff)
#define LOVR_COLOR_G(c) (c >> 16 & 0xff)
#define LOVR_COLOR_B(c) (c >> 8 & 0xff)
#define LOVR_COLOR_A(c) (c >> 0 & 0xff)
2017-01-22 02:00:32 +00:00
typedef vec_t(unsigned int) vec_uint_t;
2016-11-19 07:41:23 +00:00
typedef struct ref {
void (*free)(const struct ref* ref);
int count;
} Ref;
2016-07-07 07:04:24 +00:00
void error(const char* format, ...);
2016-11-26 07:32:48 +00:00
void lovrSleep(double seconds);
2016-11-19 07:41:23 +00:00
void* lovrAlloc(size_t size, void (*destructor)(const Ref* ref));
void lovrRetain(const Ref* ref);
void lovrRelease(const Ref* ref);
2017-02-06 09:54:11 +00:00
size_t utf8_decode(const char *s, const char *e, unsigned *pch);