Back out lovrHeadsetExtractRenderFn, don't let oculus_mobile.c pcall the render function, instead fit the render error saving inside renderHelper (emscripten/oculusmobile path). The render error is now saved in the environment at _lovrHeadsetRenderError. For this to work, luax now keeps track of a global variable for the current "main" environment.
This does means the render error path now works on emscripten (this has not been tested).
General changes:
- Amended the boot.lua error handling so when an error occurs in the error handler, the inner error is printed before quitting
- Silent quit instead of crash if a user implements lovr.errhand but it doesn't return a function
Oculus Mobile changes:
- The lovr.errhand screen is now correctly invoked for errors that occur inside lovr.draw. Multiple changes were needed to make this work:
- Instead of calling renderHelper, which uses lua_call (unsafe as Oculus Mobile does not call renderHelper) the oculus driver gets hold of the Lua ref and lua_pcalls itself. A new lovrHeadsetExtractRenderFn is added to make this possible.
- A mechanism is added where if the coroutine resume in boot.lua returns a value, boot.lua treats this as the string returned from luax_getstack and invokes lovr.errhand.
- Added a custom atpanic that routes through lovrThrow (since stderr gets eaten). With the draw() changes this should never be encountered, but it's good just in case. In current testing the tracebacks this prints don't seem to be right.
- Fix major bug in android_vthrow that meant % codes didn't work in lovrThrow on Android
- Nothing to do with errors, but fix getAxis("trigger")
This is used in the oculus mobile driver, allowing replacement of the (dubious) recursive-copy-from-zip code.
In order for this to work, the argument parsing must be beefed up a bit and also PhysFS must be updated to the newest master in order to get a new PHYSFS_setRoot. The github submodule source has been changed to one which updates more frequently to get this.
The initial version of the oculus mobile driver incorporated two files, BridgeLovr.cpp and BridgeLovr.h, which were assumed to be outside of the Lovr repo in the repo for a separate Android app. The Android app now is wholly separated and communicates with the Lovr shared object via the interface in oculus_mobile_bridge.h.
A file print_override.c now contains a drop-in replacement for Lua print() which prints to lovrLog. This is useful for Android or for other future platforms where stdout/stderr aren't usable.
The goal is to ensure that (for 3DOF devices) all poses are reported
to include the state.offset vertical transform applied to them. Previously,
only rendering was using state.offset.
This is important to fix spatial audio.
Is doing this in every driver problematic? What if we did it in the
Lua bindings? That way it could be handled in one place.
It's not very good. It only takes Transforms and sets the projection
for both eyes. And the projection gets reset at the beginning and
end of lovr.headset.renderTo. It's meant to be a backdoor.