From a1309cfe874291ba56e4f710fb5ee3ba7eb3294c Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 1 Nov 2023 14:38:04 -0700 Subject: [PATCH] Minor boot.lua refactors; --- etc/boot.lua | 101 +++++++++++++++++++++++++-------------------------- src/main.c | 5 +-- 2 files changed, 51 insertions(+), 55 deletions(-) diff --git a/etc/boot.lua b/etc/boot.lua index f6299574..d2b79bf5 100644 --- a/etc/boot.lua +++ b/etc/boot.lua @@ -1,57 +1,56 @@ lovr = require 'lovr' local lovr = lovr --- Note: Cannot be overloaded -function lovr.boot() - local conf = { - version = '0.17.0', - identity = 'default', - saveprecedence = true, - modules = { - audio = true, - data = true, - event = true, - graphics = true, - headset = true, - math = true, - physics = true, - system = true, - thread = true, - timer = true - }, - audio = { - start = true, - spatializer = nil - }, - graphics = { - debug = false, - vsync = true, - stencil = false, - antialias = true, - shadercache = true - }, - headset = { - drivers = { 'openxr', 'webxr', 'desktop' }, - supersample = false, - seated = false, - stencil = false, - antialias = true, - submitdepth = true, - overlay = false - }, - math = { - globals = true - }, - window = { - width = 720, - height = 800, - fullscreen = false, - resizable = false, - title = 'LÖVR', - icon = nil - } +local conf = { + version = '0.17.0', + identity = 'default', + saveprecedence = true, + modules = { + audio = true, + data = true, + event = true, + graphics = true, + headset = true, + math = true, + physics = true, + system = true, + thread = true, + timer = true + }, + audio = { + start = true, + spatializer = nil + }, + graphics = { + debug = false, + vsync = true, + stencil = false, + antialias = true, + shadercache = true + }, + headset = { + drivers = { 'openxr', 'webxr', 'desktop' }, + supersample = false, + seated = false, + stencil = false, + antialias = true, + submitdepth = true, + overlay = false + }, + math = { + globals = true + }, + window = { + width = 720, + height = 800, + fullscreen = false, + resizable = false, + title = 'LÖVR', + icon = nil } +} +function lovr.boot() lovr.filesystem = require('lovr.filesystem') local main = arg[0] and arg[0]:match('[^\\/]-%.lua$') or 'main.lua' local hasConf, hasMain = lovr.filesystem.isFile('conf.lua'), lovr.filesystem.isFile(main) @@ -233,7 +232,7 @@ function lovr.log(message, level, tag) print(message) end -return function() +return coroutine.create(function() local errored = false local function onerror(...) @@ -266,4 +265,4 @@ return function() coroutine.yield() end -end +end) diff --git a/src/main.c b/src/main.c index aea32194..eb7fc09d 100644 --- a/src/main.c +++ b/src/main.c @@ -111,10 +111,7 @@ int main(int argc, char** argv) { return 1; } - lua_State* T = lua_newthread(L); - lua_pushvalue(L, -2); - lua_xmove(L, T, 1); - + lua_State* T = lua_tothread(L, -1); lovrSetErrorCallback(luax_vthrow, T); lovrSetLogCallback(luax_vlog, T);