mirror of https://github.com/bjornbytes/lovr.git
Properly destroy modules on exit;
This commit is contained in:
parent
4303846eac
commit
492a75acba
|
@ -31,9 +31,10 @@ void lovrAudioInit() {
|
|||
state.device = device;
|
||||
state.context = context;
|
||||
vec_init(&state.sources);
|
||||
|
||||
vec3_set(state.position, 0, 0, 0);
|
||||
quat_set(state.orientation, 0, 0, 0, -1);
|
||||
|
||||
atexit(lovrAudioDestroy);
|
||||
}
|
||||
|
||||
void lovrAudioDestroy() {
|
||||
|
|
|
@ -18,6 +18,7 @@ void lovrEventInit() {
|
|||
vec_init(&state.events);
|
||||
lovrEventAddPump(glfwPollEvents);
|
||||
glfwSetWindowCloseCallback(window, onClose);
|
||||
atexit(lovrEventDestroy);
|
||||
}
|
||||
|
||||
void lovrEventDestroy() {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "util.h"
|
||||
#include <physfs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#elif _WIN32
|
||||
|
@ -21,6 +22,7 @@ void lovrFilesystemInit(const char* arg0) {
|
|||
|
||||
state.gameSource = NULL;
|
||||
state.identity = NULL;
|
||||
atexit(lovrFilesystemDestroy);
|
||||
}
|
||||
|
||||
void lovrFilesystemDestroy() {
|
||||
|
|
|
@ -29,6 +29,7 @@ void lovrGraphicsInit() {
|
|||
vec_init(&state.shapeIndices);
|
||||
state.depthTest = -1;
|
||||
lovrGraphicsReset();
|
||||
atexit(lovrGraphicsDestroy);
|
||||
}
|
||||
|
||||
void lovrGraphicsDestroy() {
|
||||
|
|
|
@ -10,6 +10,14 @@ void lovrHeadsetInit() {
|
|||
if (headset) {
|
||||
lovrEventAddPump(lovrHeadsetPoll);
|
||||
}
|
||||
|
||||
atexit(lovrHeadsetDestroy);
|
||||
}
|
||||
|
||||
void lovrHeadsetDestroy() {
|
||||
if (headset) {
|
||||
headset->destroy(headset);
|
||||
}
|
||||
}
|
||||
|
||||
void lovrHeadsetPoll() {
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct {
|
|||
typedef vec_t(Controller*) vec_controller_t;
|
||||
|
||||
typedef struct {
|
||||
void (*destroy)(void* headset);
|
||||
char (*isPresent)(void* headset);
|
||||
void (*poll)(void* headset);
|
||||
const char* (*getType)(void* headset);
|
||||
|
@ -61,6 +62,7 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
void lovrHeadsetInit();
|
||||
void lovrHeadsetDestroy();
|
||||
void lovrHeadsetPoll();
|
||||
char lovrHeadsetIsPresent();
|
||||
const char* lovrHeadsetGetType();
|
||||
|
|
|
@ -61,6 +61,7 @@ Headset* viveInit() {
|
|||
if (!vive) return NULL;
|
||||
|
||||
Headset* headset = (Headset*) vive;
|
||||
headset->destroy = viveDestroy;
|
||||
headset->poll = vivePoll;
|
||||
headset->isPresent = viveIsPresent;
|
||||
headset->getType = viveGetType;
|
||||
|
|
Loading…
Reference in New Issue