mirror of https://github.com/bjornbytes/lovr.git
Use lovrAssert and lovrThrow for better errors;
This commit is contained in:
parent
7f1d441cdf
commit
74f585ca8d
|
@ -389,18 +389,12 @@ int l_lovrGraphicsSetWireframe(lua_State* L) {
|
||||||
// Transforms
|
// Transforms
|
||||||
|
|
||||||
int l_lovrGraphicsPush(lua_State* L) {
|
int l_lovrGraphicsPush(lua_State* L) {
|
||||||
if (lovrGraphicsPush()) {
|
lovrGraphicsPush();
|
||||||
return luaL_error(L, "Unbalanced matrix stack (more pushes than pops?)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsPop(lua_State* L) {
|
int l_lovrGraphicsPop(lua_State* L) {
|
||||||
if (lovrGraphicsPop()) {
|
lovrGraphicsPop();
|
||||||
return luaL_error(L, "Unbalanced matrix stack (more pops than pushes?)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,11 @@ static AudioState state;
|
||||||
|
|
||||||
void lovrAudioInit() {
|
void lovrAudioInit() {
|
||||||
ALCdevice* device = alcOpenDevice(NULL);
|
ALCdevice* device = alcOpenDevice(NULL);
|
||||||
if (!device) {
|
lovrAssert(device, "Unable to open default audio device");
|
||||||
error("Unable to open default audio device");
|
|
||||||
}
|
|
||||||
|
|
||||||
ALCcontext* context = alcCreateContext(device, NULL);
|
ALCcontext* context = alcCreateContext(device, NULL);
|
||||||
if (!context || !alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR) {
|
if (!context || !alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR) {
|
||||||
error("Unable to create OpenAL context");
|
lovrThrow("Unable to create OpenAL context");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EMSCRIPTEN
|
#ifndef EMSCRIPTEN
|
||||||
|
|
|
@ -199,10 +199,7 @@ void lovrSourceSetDirection(Source* source, float x, float y, float z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrSourceSetFalloff(Source* source, float reference, float max, float rolloff) {
|
void lovrSourceSetFalloff(Source* source, float reference, float max, float rolloff) {
|
||||||
if (lovrSourceGetChannels(source) != 1) {
|
lovrAssert(lovrSourceGetChannels(source) == 1, "Positional audio is only supported for mono sources");
|
||||||
error("Positional audio is only supported for mono sources.");
|
|
||||||
}
|
|
||||||
|
|
||||||
alSourcef(source->id, AL_REFERENCE_DISTANCE, reference);
|
alSourcef(source->id, AL_REFERENCE_DISTANCE, reference);
|
||||||
alSourcef(source->id, AL_MAX_DISTANCE, max);
|
alSourcef(source->id, AL_MAX_DISTANCE, max);
|
||||||
alSourcef(source->id, AL_ROLLOFF_FACTOR, rolloff);
|
alSourcef(source->id, AL_ROLLOFF_FACTOR, rolloff);
|
||||||
|
@ -217,10 +214,7 @@ void lovrSourceSetPitch(Source* source, float pitch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrSourceSetPosition(Source* source, float x, float y, float z) {
|
void lovrSourceSetPosition(Source* source, float x, float y, float z) {
|
||||||
if (lovrSourceGetChannels(source) != 1) {
|
lovrAssert(lovrSourceGetChannels(source) == 1, "Positional audio is only supported for mono sources");
|
||||||
error("Positional audio is only supported for mono sources.");
|
|
||||||
}
|
|
||||||
|
|
||||||
alSource3f(source->id, AL_POSITION, x, y, z);
|
alSource3f(source->id, AL_POSITION, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ static FilesystemState state;
|
||||||
|
|
||||||
void lovrFilesystemInit(const char* arg0, const char* arg1) {
|
void lovrFilesystemInit(const char* arg0, const char* arg1) {
|
||||||
if (!PHYSFS_init(arg0)) {
|
if (!PHYSFS_init(arg0)) {
|
||||||
error("Could not initialize filesystem: %s", PHYSFS_getLastError());
|
lovrThrow("Could not initialize filesystem: %s", PHYSFS_getLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
state.source = malloc(LOVR_PATH_MAX * sizeof(char));
|
state.source = malloc(LOVR_PATH_MAX * sizeof(char));
|
||||||
|
@ -111,7 +111,7 @@ int lovrFilesystemGetExecutablePath(char* dest, unsigned int size) {
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
memset(dest, 0, size);
|
memset(dest, 0, size);
|
||||||
if (readlink("/proc/self/exe", dest, size) == -1) {
|
if (readlink("/proc/self/exe", dest, size) == -1) {
|
||||||
perror("readlink");
|
return 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error "This platform is missing an implementation for lovrFilesystemGetExecutablePath"
|
#error "This platform is missing an implementation for lovrFilesystemGetExecutablePath"
|
||||||
|
@ -230,7 +230,7 @@ int lovrFilesystemSetIdentity(const char* identity) {
|
||||||
strncpy(state.savePathFull, fullPathBuffer, LOVR_PATH_MAX);
|
strncpy(state.savePathFull, fullPathBuffer, LOVR_PATH_MAX);
|
||||||
PHYSFS_mkdir(state.savePathRelative);
|
PHYSFS_mkdir(state.savePathRelative);
|
||||||
if (!PHYSFS_setWriteDir(state.savePathFull)) {
|
if (!PHYSFS_setWriteDir(state.savePathFull)) {
|
||||||
error("Could not set write directory: %s (%s)", PHYSFS_getLastError(), state.savePathRelative);
|
lovrThrow("Could not set write directory: %s (%s)", PHYSFS_getLastError(), state.savePathRelative);
|
||||||
}
|
}
|
||||||
|
|
||||||
PHYSFS_mount(state.savePathFull, NULL, 0);
|
PHYSFS_mount(state.savePathFull, NULL, 0);
|
||||||
|
|
|
@ -91,9 +91,7 @@ void lovrGraphicsPrepare() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsCreateWindow(int w, int h, int fullscreen, int msaa, const char* title, const char* icon) {
|
void lovrGraphicsCreateWindow(int w, int h, int fullscreen, int msaa, const char* title, const char* icon) {
|
||||||
if (state.window) {
|
lovrAssert(!state.window, "Window is already created");
|
||||||
error("Window is already created");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
|
@ -120,7 +118,7 @@ void lovrGraphicsCreateWindow(int w, int h, int fullscreen, int msaa, const char
|
||||||
state.window = glfwCreateWindow(w ? w : mode->width, h ? h : mode->height, title, fullscreen ? monitor : NULL, NULL);
|
state.window = glfwCreateWindow(w ? w : mode->width, h ? h : mode->height, title, fullscreen ? monitor : NULL, NULL);
|
||||||
if (!state.window) {
|
if (!state.window) {
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
error("Could not create window");
|
lovrThrow("Could not create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
|
@ -374,14 +372,18 @@ void lovrGraphicsSetWireframe(int wireframe) {
|
||||||
|
|
||||||
// Transforms
|
// Transforms
|
||||||
|
|
||||||
int lovrGraphicsPush() {
|
void lovrGraphicsPush() {
|
||||||
if (++state.transform >= MAX_TRANSFORMS) { return 1; }
|
if (++state.transform >= MAX_TRANSFORMS) {
|
||||||
memcpy(state.transforms[state.transform], state.transforms[state.transform - 1], 16 * sizeof(float));
|
lovrThrow("Unbalanced matrix stack (more pushes than pops?)");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int lovrGraphicsPop() {
|
memcpy(state.transforms[state.transform], state.transforms[state.transform - 1], 16 * sizeof(float));
|
||||||
return --state.transform < 0;
|
}
|
||||||
|
|
||||||
|
void lovrGraphicsPop() {
|
||||||
|
if (--state.transform < 0) {
|
||||||
|
lovrThrow("Unbalanced matrix stack (more pops than pushes?)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsOrigin() {
|
void lovrGraphicsOrigin() {
|
||||||
|
@ -870,7 +872,7 @@ void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAl
|
||||||
// Internal State
|
// Internal State
|
||||||
void lovrGraphicsPushCanvas() {
|
void lovrGraphicsPushCanvas() {
|
||||||
if (++state.canvas >= MAX_CANVASES) {
|
if (++state.canvas >= MAX_CANVASES) {
|
||||||
error("Canvas overflow");
|
lovrThrow("Canvas overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&state.canvases[state.canvas], &state.canvases[state.canvas - 1], sizeof(CanvasState));
|
memcpy(&state.canvases[state.canvas], &state.canvases[state.canvas - 1], sizeof(CanvasState));
|
||||||
|
@ -878,7 +880,7 @@ void lovrGraphicsPushCanvas() {
|
||||||
|
|
||||||
void lovrGraphicsPopCanvas() {
|
void lovrGraphicsPopCanvas() {
|
||||||
if (--state.canvas < 0) {
|
if (--state.canvas < 0) {
|
||||||
error("Canvas underflow");
|
lovrThrow("Canvas underflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
int* viewport = state.canvases[state.canvas].viewport;
|
int* viewport = state.canvases[state.canvas].viewport;
|
||||||
|
|
|
@ -137,8 +137,8 @@ int lovrGraphicsIsWireframe();
|
||||||
void lovrGraphicsSetWireframe(int wireframe);
|
void lovrGraphicsSetWireframe(int wireframe);
|
||||||
|
|
||||||
// Transforms
|
// Transforms
|
||||||
int lovrGraphicsPush();
|
void lovrGraphicsPush();
|
||||||
int lovrGraphicsPop();
|
void lovrGraphicsPop();
|
||||||
void lovrGraphicsOrigin();
|
void lovrGraphicsOrigin();
|
||||||
void lovrGraphicsTranslate(float x, float y, float z);
|
void lovrGraphicsTranslate(float x, float y, float z);
|
||||||
void lovrGraphicsRotate(float angle, float ax, float ay, float az);
|
void lovrGraphicsRotate(float angle, float ax, float ay, float az);
|
||||||
|
|
|
@ -99,7 +99,7 @@ static GLuint compileShader(GLenum type, const char* source) {
|
||||||
|
|
||||||
char* log = (char*) malloc(logLength);
|
char* log = (char*) malloc(logLength);
|
||||||
glGetShaderInfoLog(shader, logLength, &logLength, log);
|
glGetShaderInfoLog(shader, logLength, &logLength, log);
|
||||||
error(log);
|
lovrThrow("Could not compile shader %s", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
return shader;
|
return shader;
|
||||||
|
@ -130,7 +130,7 @@ static GLuint linkShaders(GLuint vertexShader, GLuint fragmentShader) {
|
||||||
|
|
||||||
char* log = (char*) malloc(logLength);
|
char* log = (char*) malloc(logLength);
|
||||||
glGetProgramInfoLog(shader, logLength, &logLength, log);
|
glGetProgramInfoLog(shader, logLength, &logLength, log);
|
||||||
error(log);
|
lovrThrow("Could not link shader %s", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDetachShader(shader, vertexShader);
|
glDetachShader(shader, vertexShader);
|
||||||
|
@ -196,7 +196,7 @@ Shader* lovrShaderCreateDefault(DefaultShader type) {
|
||||||
case SHADER_SKYBOX: return lovrShaderCreate(lovrSkyboxVertexShader, lovrSkyboxFragmentShader);
|
case SHADER_SKYBOX: return lovrShaderCreate(lovrSkyboxVertexShader, lovrSkyboxFragmentShader);
|
||||||
case SHADER_FONT: return lovrShaderCreate(NULL, lovrFontFragmentShader);
|
case SHADER_FONT: return lovrShaderCreate(NULL, lovrFontFragmentShader);
|
||||||
case SHADER_FULLSCREEN: return lovrShaderCreate(lovrNoopVertexShader, NULL);
|
case SHADER_FULLSCREEN: return lovrShaderCreate(lovrNoopVertexShader, NULL);
|
||||||
default: error("Unknown default shader type");
|
default: lovrThrow("Unknown default shader type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,7 @@ Skybox* lovrSkyboxCreate(Blob** blobs, SkyboxType type) {
|
||||||
int width, height, channels;
|
int width, height, channels;
|
||||||
stbi_set_flip_vertically_on_load(0);
|
stbi_set_flip_vertically_on_load(0);
|
||||||
unsigned char* image = stbi_load_from_memory(blobs[i]->data, blobs[i]->size, &width, &height, &channels, 3);
|
unsigned char* image = stbi_load_from_memory(blobs[i]->data, blobs[i]->size, &width, &height, &channels, 3);
|
||||||
|
lovrAssert(image, "Could not load skybox image %d", i);
|
||||||
if (!image) {
|
|
||||||
error("Could not load skybox image %d", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == SKYBOX_CUBE) {
|
if (type == SKYBOX_CUBE) {
|
||||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
|
|
|
@ -93,13 +93,9 @@ Texture* lovrTextureCreateWithFramebuffer(TextureData* textureData, TextureProje
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, texture->framebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, texture->framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
lovrAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Error creating texture");
|
||||||
error("Error creating texture\n");
|
|
||||||
} else {
|
|
||||||
lovrGraphicsClear(1, 1);
|
lovrGraphicsClear(1, 1);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +110,7 @@ void lovrTextureDestroy(const Ref* ref) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrTextureBindFramebuffer(Texture* texture) {
|
void lovrTextureBindFramebuffer(Texture* texture) {
|
||||||
if (!texture->framebuffer) {
|
lovrAssert(texture->framebuffer, "Texture cannot be used as a canvas");
|
||||||
error("Texture cannot be used as a canvas");
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = texture->textureData->width;
|
int w = texture->textureData->width;
|
||||||
int h = texture->textureData->height;
|
int h = texture->textureData->height;
|
||||||
|
|
|
@ -461,7 +461,7 @@ float lovrHeadsetControllerGetAxis(Controller* controller, ControllerAxis axis)
|
||||||
case CONTROLLER_AXIS_TRIGGER: return input.rAxis[1].x;
|
case CONTROLLER_AXIS_TRIGGER: return input.rAxis[1].x;
|
||||||
case CONTROLLER_AXIS_TOUCHPAD_X: return input.rAxis[0].x;
|
case CONTROLLER_AXIS_TOUCHPAD_X: return input.rAxis[0].x;
|
||||||
case CONTROLLER_AXIS_TOUCHPAD_Y: return input.rAxis[0].y;
|
case CONTROLLER_AXIS_TOUCHPAD_Y: return input.rAxis[0].y;
|
||||||
default: error("Bad controller axis");
|
default: lovrThrow("Bad controller axis");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.;
|
return 0.;
|
||||||
|
@ -487,7 +487,7 @@ int lovrHeadsetControllerIsDown(Controller* controller, ControllerButton button)
|
||||||
return (input.ulButtonPressed >> EVRButtonId_k_EButton_SteamVR_Touchpad) & 1;
|
return (input.ulButtonPressed >> EVRButtonId_k_EButton_SteamVR_Touchpad) & 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error("Bad controller button");
|
lovrThrow("Bad controller button");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -62,7 +62,7 @@ static int ftCubicTo(const FT_Vector* control1, const FT_Vector* control2, const
|
||||||
|
|
||||||
FontData* lovrFontDataCreate(Blob* blob, int size) {
|
FontData* lovrFontDataCreate(Blob* blob, int size) {
|
||||||
if (!ft && FT_Init_FreeType(&ft)) {
|
if (!ft && FT_Init_FreeType(&ft)) {
|
||||||
error("Error initializing FreeType");
|
lovrThrow("Error initializing FreeType");
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Face face = NULL;
|
FT_Face face = NULL;
|
||||||
|
@ -75,10 +75,7 @@ FontData* lovrFontDataCreate(Blob* blob, int size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = err || FT_Set_Pixel_Sizes(face, 0, size);
|
err = err || FT_Set_Pixel_Sizes(face, 0, size);
|
||||||
|
lovrAssert(!err, "Problem loading font");
|
||||||
if (err) {
|
|
||||||
error("Problem loading font");
|
|
||||||
}
|
|
||||||
|
|
||||||
FontData* fontData = malloc(sizeof(FontData));
|
FontData* fontData = malloc(sizeof(FontData));
|
||||||
fontData->rasterizer = face;
|
fontData->rasterizer = face;
|
||||||
|
@ -117,9 +114,7 @@ void lovrFontDataLoadGlyph(FontData* fontData, uint32_t character, Glyph* glyph)
|
||||||
|
|
||||||
err = err || FT_Load_Glyph(face, FT_Get_Char_Index(face, character), FT_LOAD_DEFAULT);
|
err = err || FT_Load_Glyph(face, FT_Get_Char_Index(face, character), FT_LOAD_DEFAULT);
|
||||||
err = err || FT_Outline_Decompose(&face->glyph->outline, &callbacks, &context);
|
err = err || FT_Outline_Decompose(&face->glyph->outline, &callbacks, &context);
|
||||||
if (err) {
|
lovrAssert(!err, "Error loading glyph");
|
||||||
error("Error loading glyph");
|
|
||||||
}
|
|
||||||
|
|
||||||
metrics = &face->glyph->metrics;
|
metrics = &face->glyph->metrics;
|
||||||
|
|
||||||
|
|
|
@ -70,9 +70,7 @@ ModelData* lovrModelDataCreate(Blob* blob) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normals
|
// Normals
|
||||||
if (!assimpMesh->mNormals) {
|
lovrAssert(assimpMesh->mNormals, "Model must have normals");
|
||||||
error("Model must have normals");
|
|
||||||
}
|
|
||||||
|
|
||||||
modelData->hasNormals = 1;
|
modelData->hasNormals = 1;
|
||||||
vec_init(&mesh->normals);
|
vec_init(&mesh->normals);
|
||||||
|
|
|
@ -183,7 +183,7 @@ TextureData* lovrTextureDataFromBlob(Blob* blob) {
|
||||||
textureData->blob = NULL;
|
textureData->blob = NULL;
|
||||||
|
|
||||||
if (!textureData->data) {
|
if (!textureData->data) {
|
||||||
error("Could not load texture data from '%s'", blob->name);
|
lovrThrow("Could not load texture data from '%s'", blob->name);
|
||||||
free(textureData);
|
free(textureData);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ TextureData* lovrTextureDataFromBlob(Blob* blob) {
|
||||||
|
|
||||||
void lovrTextureDataResize(TextureData* textureData, int width, int height, uint8_t value) {
|
void lovrTextureDataResize(TextureData* textureData, int width, int height, uint8_t value) {
|
||||||
if (textureData->format.compressed || textureData->mipmaps.generated) {
|
if (textureData->format.compressed || textureData->mipmaps.generated) {
|
||||||
error("Can't resize a compressed texture or a texture with generated mipmaps.");
|
lovrThrow("Can't resize a compressed texture or a texture with generated mipmaps.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = width * height * textureData->format.blockBytes;
|
int size = width * height * textureData->format.blockBytes;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
static int hasErrored = 0;
|
static int hasErrored = 0;
|
||||||
|
|
||||||
static void onGlfwError(int code, const char* description) {
|
static void onGlfwError(int code, const char* description) {
|
||||||
error(description);
|
lovrThrow(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getStackTrace(lua_State* L) {
|
static int getStackTrace(lua_State* L) {
|
||||||
|
@ -31,7 +31,7 @@ static void handleError(lua_State* L, const char* message) {
|
||||||
lua_pushstring(L, message);
|
lua_pushstring(L, message);
|
||||||
lua_pcall(L, 1, 0, 0);
|
lua_pcall(L, 1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
error(message);
|
fprintf(stderr, "%s\n", message);
|
||||||
}
|
}
|
||||||
lovrDestroy(1);
|
lovrDestroy(1);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void lovrInit(lua_State* L, int argc, char** argv) {
|
||||||
glfwSetErrorCallback(onGlfwError);
|
glfwSetErrorCallback(onGlfwError);
|
||||||
|
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
error("Error initializing glfw");
|
lovrThrow("Error initializing glfw");
|
||||||
}
|
}
|
||||||
|
|
||||||
// arg global
|
// arg global
|
||||||
|
|
|
@ -258,10 +258,7 @@ int lovrWorldIsCollisionEnabledBetween(World* world, const char* tag1, const cha
|
||||||
}
|
}
|
||||||
|
|
||||||
Collider* lovrColliderCreate(World* world, float x, float y, float z) {
|
Collider* lovrColliderCreate(World* world, float x, float y, float z) {
|
||||||
if (!world) {
|
lovrAssert(world, "No world specified");
|
||||||
error("No world specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
Collider* collider = lovrAlloc(sizeof(Collider), lovrColliderDestroy);
|
Collider* collider = lovrAlloc(sizeof(Collider), lovrColliderDestroy);
|
||||||
if (!collider) return NULL;
|
if (!collider) return NULL;
|
||||||
|
|
||||||
|
@ -888,10 +885,7 @@ void lovrJointSetUserData(Joint* joint, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BallJoint* lovrBallJointCreate(Collider* a, Collider* b, float x, float y, float z) {
|
BallJoint* lovrBallJointCreate(Collider* a, Collider* b, float x, float y, float z) {
|
||||||
if (a->world != b->world) {
|
lovrAssert(a->world == b->world, "Joint bodies must exist in same World");
|
||||||
error("Joint bodies must exist in same World");
|
|
||||||
}
|
|
||||||
|
|
||||||
BallJoint* joint = lovrAlloc(sizeof(BallJoint), lovrJointDestroy);
|
BallJoint* joint = lovrAlloc(sizeof(BallJoint), lovrJointDestroy);
|
||||||
if (!joint) return NULL;
|
if (!joint) return NULL;
|
||||||
|
|
||||||
|
@ -921,10 +915,7 @@ void lovrBallJointSetAnchor(BallJoint* joint, float x, float y, float z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DistanceJoint* lovrDistanceJointCreate(Collider* a, Collider* b, float x1, float y1, float z1, float x2, float y2, float z2) {
|
DistanceJoint* lovrDistanceJointCreate(Collider* a, Collider* b, float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||||
if (a->world != b->world) {
|
lovrAssert(a->world == b->world, "Joint bodies must exist in same World");
|
||||||
error("Joint bodies must exist in same World");
|
|
||||||
}
|
|
||||||
|
|
||||||
DistanceJoint* joint = lovrAlloc(sizeof(DistanceJoint), lovrJointDestroy);
|
DistanceJoint* joint = lovrAlloc(sizeof(DistanceJoint), lovrJointDestroy);
|
||||||
if (!joint) return NULL;
|
if (!joint) return NULL;
|
||||||
|
|
||||||
|
@ -963,10 +954,7 @@ void lovrDistanceJointSetDistance(DistanceJoint* joint, float distance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HingeJoint* lovrHingeJointCreate(Collider* a, Collider* b, float x, float y, float z, float ax, float ay, float az) {
|
HingeJoint* lovrHingeJointCreate(Collider* a, Collider* b, float x, float y, float z, float ax, float ay, float az) {
|
||||||
if (a->world != b->world) {
|
lovrAssert(a->world == b->world, "Joint bodies must exist in same World");
|
||||||
error("Joint bodies must exist in same World");
|
|
||||||
}
|
|
||||||
|
|
||||||
HingeJoint* joint = lovrAlloc(sizeof(HingeJoint), lovrJointDestroy);
|
HingeJoint* joint = lovrAlloc(sizeof(HingeJoint), lovrJointDestroy);
|
||||||
if (!joint) return NULL;
|
if (!joint) return NULL;
|
||||||
|
|
||||||
|
@ -1029,10 +1017,7 @@ void lovrHingeJointSetUpperLimit(HingeJoint* joint, float limit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SliderJoint* lovrSliderJointCreate(Collider* a, Collider* b, float ax, float ay, float az) {
|
SliderJoint* lovrSliderJointCreate(Collider* a, Collider* b, float ax, float ay, float az) {
|
||||||
if (a->world != b->world) {
|
lovrAssert(a->world == b->world, "Joint bodies must exist in the same world");
|
||||||
error("Joint bodies must exist in same World");
|
|
||||||
}
|
|
||||||
|
|
||||||
SliderJoint* joint = lovrAlloc(sizeof(SliderJoint), lovrJointDestroy);
|
SliderJoint* joint = lovrAlloc(sizeof(SliderJoint), lovrJointDestroy);
|
||||||
if (!joint) return NULL;
|
if (!joint) return NULL;
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,6 @@
|
||||||
char lovrErrorMessage[MAX_ERROR_LENGTH];
|
char lovrErrorMessage[MAX_ERROR_LENGTH];
|
||||||
jmp_buf* lovrCatch;
|
jmp_buf* lovrCatch;
|
||||||
|
|
||||||
void error(const char* format, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
vfprintf(stderr, format, args);
|
|
||||||
fputs("\n", stderr);
|
|
||||||
va_end(args);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lovrThrow(const char* format, ...) {
|
void lovrThrow(const char* format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
|
@ -22,7 +22,6 @@ typedef struct {
|
||||||
extern char lovrErrorMessage[];
|
extern char lovrErrorMessage[];
|
||||||
extern jmp_buf* lovrCatch;
|
extern jmp_buf* lovrCatch;
|
||||||
|
|
||||||
void error(const char* format, ...);
|
|
||||||
void lovrThrow(const char* format, ...);
|
void lovrThrow(const char* format, ...);
|
||||||
void lovrSleep(double seconds);
|
void lovrSleep(double seconds);
|
||||||
void* lovrAlloc(size_t size, void (*destructor)(const Ref* ref));
|
void* lovrAlloc(size_t size, void (*destructor)(const Ref* ref));
|
||||||
|
|
Loading…
Reference in New Issue