t.graphics.debug flag;

This commit is contained in:
bjorn 2020-07-28 16:12:15 -06:00
parent 5a17b48e4e
commit e3aa4c7d5d
6 changed files with 24 additions and 6 deletions

View File

@ -1741,9 +1741,20 @@ int luaopen_lovr_graphics(lua_State* L) {
luax_registertype(L, Shader);
luax_registertype(L, ShaderBlock);
luax_registertype(L, Texture);
lovrGraphicsInit();
luax_pushconf(L);
bool debug = false;
lua_getfield(L, -1, "graphics");
if (lua_istable(L, -1)) {
lua_getfield(L, -1, "debug");
debug = lua_toboolean(L, -1);
lua_pop(L, 1);
}
lua_pop(L, 1);
lovrGraphicsInit(debug);
lua_pushcfunction(L, l_lovrGraphicsCreateWindow);
lua_getfield(L, -2, "window");
lua_call(L, 1, 0);

View File

@ -9,6 +9,7 @@ typedef struct {
uint32_t height;
bool fullscreen;
bool resizable;
bool debug;
int vsync;
int msaa;
const char* title;

View File

@ -92,6 +92,7 @@ typedef struct {
static struct {
bool initialized;
bool debug;
int width;
int height;
Camera camera;
@ -188,7 +189,8 @@ static void* lovrGraphicsMapBuffer(StreamType type, uint32_t count) {
// Base
bool lovrGraphicsInit() {
bool lovrGraphicsInit(bool debug) {
state.debug = debug;
return false; // See lovrGraphicsCreateWindow for actual initialization
}
@ -221,12 +223,13 @@ void lovrGraphicsPresent() {
}
void lovrGraphicsCreateWindow(WindowFlags* flags) {
flags->debug = state.debug;
lovrAssert(!state.initialized, "Window is already created");
lovrAssert(lovrPlatformCreateWindow(flags), "Could not create window");
lovrPlatformOnQuitRequest(onQuitRequest);
lovrPlatformOnWindowResize(onResizeWindow);
lovrPlatformGetFramebufferSize(&state.width, &state.height);
lovrGpuInit(lovrPlatformGetProcAddress);
lovrGpuInit(lovrPlatformGetProcAddress, state.debug);
state.defaultCanvas = lovrCanvasCreateFromHandle(state.width, state.height, (CanvasFlags) { .stereo = false }, 0, 0, 0, 1, true);

View File

@ -92,7 +92,7 @@ typedef struct {
} Pipeline;
// Base
bool lovrGraphicsInit(void);
bool lovrGraphicsInit(bool debug);
void lovrGraphicsDestroy(void);
void lovrGraphicsPresent(void);
void lovrGraphicsCreateWindow(WindowFlags* flags);
@ -219,7 +219,7 @@ typedef struct {
uint32_t instances;
} DrawCommand;
void lovrGpuInit(void* (*getProcAddress)(const char*));
void lovrGpuInit(void* (*getProcAddress)(const char*), bool debug);
void lovrGpuDestroy(void);
void lovrGpuClear(struct Canvas* canvas, Color* color, float* depth, int* stencil);
void lovrGpuCompute(struct Shader* shader, int x, int y, int z);

View File

@ -1226,7 +1226,7 @@ static void lovrGpuSetViewports(float* viewport, uint32_t count) {
// GPU
void lovrGpuInit(void* (*getProcAddress)(const char*)) {
void lovrGpuInit(void* (*getProcAddress)(const char*), bool debug) {
#ifdef LOVR_GL
gladLoadGLLoader((GLADloadproc) getProcAddress);
#elif defined(LOVR_GLES)

View File

@ -95,6 +95,9 @@ function lovr.boot()
thread = true,
timer = true
},
graphics = {
debug = false
},
headset = {
drivers = { 'leap', 'openxr', 'oculus', 'vrapi', 'pico', 'openvr', 'webxr', 'webvr', 'desktop' },
offset = 1.7,