mirror of https://github.com/bjornbytes/lovr.git
api doesn't include util;
This commit is contained in:
parent
9bdceb0094
commit
3bc2c00b79
|
@ -4,7 +4,6 @@
|
||||||
#include "core/util.h"
|
#include "core/util.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
typedef void voidFn(void);
|
typedef void voidFn(void);
|
||||||
typedef void destructorFn(void*);
|
typedef void destructorFn(void*);
|
||||||
|
|
|
@ -3,10 +3,17 @@
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "core/util.h"
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct Color;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define LOVR_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define LOVR_EXPORT __attribute__((visibility("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
LOVR_EXPORT int luaopen_lovr(lua_State* L);
|
LOVR_EXPORT int luaopen_lovr(lua_State* L);
|
||||||
LOVR_EXPORT int luaopen_lovr_audio(lua_State* L);
|
LOVR_EXPORT int luaopen_lovr_audio(lua_State* L);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
||||||
#include "core/maf.h"
|
#include "core/maf.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
StringEntry lovrSourceType[] = {
|
StringEntry lovrSourceType[] = {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int l_lovrMicrophoneGetBitDepth(lua_State* L) {
|
static int l_lovrMicrophoneGetBitDepth(lua_State* L) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "core/maf.h"
|
#include "core/maf.h"
|
||||||
#include <stdbool.h>
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrSourceGetBitDepth(lua_State* L) {
|
static int l_lovrSourceGetBitDepth(lua_State* L) {
|
||||||
Source* source = luax_checktype(L, 1, Source);
|
Source* source = luax_checktype(L, 1, Source);
|
||||||
|
@ -227,8 +227,7 @@ static int l_lovrSourceSetPosition(lua_State* L) {
|
||||||
|
|
||||||
static int l_lovrSourceSetRelative(lua_State* L) {
|
static int l_lovrSourceSetRelative(lua_State* L) {
|
||||||
Source* source = luax_checktype(L, 1, Source);
|
Source* source = luax_checktype(L, 1, Source);
|
||||||
bool isRelative = lua_toboolean(L, 2);
|
lovrSourceSetRelative(source, lua_toboolean(L, 2));
|
||||||
lovrSourceSetRelative(source, isRelative);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "data/audioStream.h"
|
#include "data/audioStream.h"
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "data/blob.h"
|
#include "data/blob.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrBlobGetName(lua_State* L) {
|
static int l_lovrBlobGetName(lua_State* L) {
|
||||||
Blob* blob = luax_checktype(L, 1, Blob);
|
Blob* blob = luax_checktype(L, 1, Blob);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "data/rasterizer.h"
|
#include "data/rasterizer.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrRasterizerGetHeight(lua_State* L) {
|
static int l_lovrRasterizerGetHeight(lua_State* L) {
|
||||||
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
|
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrSoundDataGetBitDepth(lua_State* L) {
|
static int l_lovrSoundDataGetBitDepth(lua_State* L) {
|
||||||
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "core/fs.h"
|
#include "core/fs.h"
|
||||||
#include "core/os.h"
|
#include "core/os.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "graphics/font.h"
|
#include "graphics/font.h"
|
||||||
#include "data/rasterizer.h"
|
#include "data/rasterizer.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrFontGetWidth(lua_State* L) {
|
static int l_lovrFontGetWidth(lua_State* L) {
|
||||||
Font* font = luax_checktype(L, 1, Font);
|
Font* font = luax_checktype(L, 1, Font);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "math/randomGenerator.h"
|
#include "math/randomGenerator.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static double luax_checkrandomseedpart(lua_State* L, int index) {
|
static double luax_checkrandomseedpart(lua_State* L, int index) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "math/math.h"
|
#include "math/math.h"
|
||||||
#include "core/maf.h"
|
#include "core/maf.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static const uint32_t* swizzles[5] = {
|
static const uint32_t* swizzles[5] = {
|
||||||
[2] = (uint32_t[]) {
|
[2] = (uint32_t[]) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
StringEntry lovrShapeType[] = {
|
StringEntry lovrShapeType[] = {
|
||||||
[SHAPE_SPHERE] = ENTRY("sphere"),
|
[SHAPE_SPHERE] = ENTRY("sphere"),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
static int l_lovrColliderDestroy(lua_State* L) {
|
static int l_lovrColliderDestroy(lua_State* L) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
void luax_pushjoint(lua_State* L, Joint* joint) {
|
void luax_pushjoint(lua_State* L, Joint* joint) {
|
||||||
switch (joint->type) {
|
switch (joint->type) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
void luax_pushshape(lua_State* L, Shape* shape) {
|
void luax_pushshape(lua_State* L, Shape* shape) {
|
||||||
switch (shape->type) {
|
switch (shape->type) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
static void collisionResolver(World* world, void* userdata) {
|
static void collisionResolver(World* world, void* userdata) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "thread/thread.h"
|
#include "thread/thread.h"
|
||||||
#include "thread/channel.h"
|
#include "thread/channel.h"
|
||||||
#include "core/ref.h"
|
#include "core/ref.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "thread/channel.h"
|
#include "thread/channel.h"
|
||||||
#include "event/event.h"
|
#include "event/event.h"
|
||||||
|
#include "core/util.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static void luax_checktimeout(lua_State* L, int index, double* timeout) {
|
static void luax_checktimeout(lua_State* L, int index, double* timeout) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "thread/thread.h"
|
#include "thread/thread.h"
|
||||||
|
#include "core/util.h"
|
||||||
|
|
||||||
static int l_lovrThreadStart(lua_State* L) {
|
static int l_lovrThreadStart(lua_State* L) {
|
||||||
Thread* thread = luax_checktype(L, 1, Thread);
|
Thread* thread = luax_checktype(L, 1, Thread);
|
||||||
|
|
|
@ -94,10 +94,10 @@ MAF vec3 vec3_lerp(vec3 v, const vec3 u, float t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MAF vec3 vec3_min(vec3 v, const vec3 u) {
|
MAF vec3 vec3_min(vec3 v, const vec3 u) {
|
||||||
float x = MIN(v[0], u[0]);
|
float x = v[0] < u[0] ? v[0] : u[0];
|
||||||
float y = MIN(v[1], u[1]);
|
float y = v[1] < u[1] ? v[1] : u[1];
|
||||||
float z = MIN(v[2], u[2]);
|
float z = v[2] < u[2] ? v[2] : u[2];
|
||||||
float w = MIN(v[3], u[3]);
|
float w = v[3] < u[3] ? v[3] : u[3];
|
||||||
v[0] = x;
|
v[0] = x;
|
||||||
v[1] = y;
|
v[1] = y;
|
||||||
v[2] = z;
|
v[2] = z;
|
||||||
|
@ -106,10 +106,10 @@ MAF vec3 vec3_min(vec3 v, const vec3 u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MAF vec3 vec3_max(vec3 v, const vec3 u) {
|
MAF vec3 vec3_max(vec3 v, const vec3 u) {
|
||||||
float x = MAX(v[0], u[0]);
|
float x = v[0] > u[0] ? v[0] : u[0];
|
||||||
float y = MAX(v[1], u[1]);
|
float y = v[1] > u[1] ? v[1] : u[1];
|
||||||
float z = MAX(v[2], u[2]);
|
float z = v[2] > u[2] ? v[2] : u[2];
|
||||||
float w = MAX(v[3], u[3]);
|
float w = v[3] > u[3] ? v[3] : u[3];
|
||||||
v[0] = x;
|
v[0] = x;
|
||||||
v[1] = y;
|
v[1] = y;
|
||||||
v[2] = z;
|
v[2] = z;
|
||||||
|
@ -142,10 +142,14 @@ MAF quat quat_fromAngleAxis(quat q, float angle, float ax, float ay, float az) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MAF quat quat_fromMat4(quat q, mat4 m) {
|
MAF quat quat_fromMat4(quat q, mat4 m) {
|
||||||
float x = sqrtf(MAX(0.f, 1.f + m[0] - m[5] - m[10])) / 2.f;
|
float a = 1.f + m[0] - m[5] - m[10];
|
||||||
float y = sqrtf(MAX(0.f, 1.f - m[0] + m[5] - m[10])) / 2.f;
|
float b = 1.f - m[0] + m[5] - m[10];
|
||||||
float z = sqrtf(MAX(0.f, 1.f - m[0] - m[5] + m[10])) / 2.f;
|
float c = 1.f - m[0] - m[5] + m[10];
|
||||||
float w = sqrtf(MAX(0.f, 1.f + m[0] + m[5] + m[10])) / 2.f;
|
float d = 1.f + m[0] + m[5] + m[10];
|
||||||
|
float x = sqrtf(a > 0.f ? a : 0.f) / 2.f;
|
||||||
|
float y = sqrtf(b > 0.f ? b : 0.f) / 2.f;
|
||||||
|
float z = sqrtf(c > 0.f ? c : 0.f) / 2.f;
|
||||||
|
float w = sqrtf(d > 0.f ? d : 0.f) / 2.f;
|
||||||
x = (m[9] - m[6]) > 0.f ? -x : x;
|
x = (m[9] - m[6]) > 0.f ? -x : x;
|
||||||
y = (m[2] - m[8]) > 0.f ? -y : y;
|
y = (m[2] - m[8]) > 0.f ? -y : y;
|
||||||
z = (m[4] - m[1]) > 0.f ? -z : z;
|
z = (m[4] - m[1]) > 0.f ? -z : z;
|
||||||
|
|
|
@ -10,13 +10,11 @@
|
||||||
#define LOVR_VERSION_ALIAS "Maximum Moss"
|
#define LOVR_VERSION_ALIAS "Maximum Moss"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define LOVR_EXPORT __declspec(dllexport)
|
|
||||||
#define LOVR_NORETURN __declspec(noreturn)
|
#define LOVR_NORETURN __declspec(noreturn)
|
||||||
#define LOVR_THREAD_LOCAL __declspec(thread)
|
#define LOVR_THREAD_LOCAL __declspec(thread)
|
||||||
#define LOVR_ALIGN(n) __declspec(align(n))
|
#define LOVR_ALIGN(n) __declspec(align(n))
|
||||||
#define LOVR_RESTRICT __restrict
|
#define LOVR_RESTRICT __restrict
|
||||||
#else
|
#else
|
||||||
#define LOVR_EXPORT __attribute__((visibility("default")))
|
|
||||||
#define LOVR_NORETURN __attribute__((noreturn))
|
#define LOVR_NORETURN __attribute__((noreturn))
|
||||||
#define LOVR_THREAD_LOCAL __thread
|
#define LOVR_THREAD_LOCAL __thread
|
||||||
#define LOVR_ALIGN(n) __attribute__((aligned(n)))
|
#define LOVR_ALIGN(n) __attribute__((aligned(n)))
|
||||||
|
|
Loading…
Reference in New Issue