Commit Graph

3267 Commits

Author SHA1 Message Date
bjorn 7984baad65 os_linux: implement virtual memory allocator; 2021-07-09 18:39:23 -07:00
bjorn f959770396 Add missing OpenVR pointer actions; 2021-06-29 13:09:57 -07:00
bjorn 8ef2b064fd Fix ShaderBlock:send(Blob) error message; 2021-06-28 22:39:16 -07:00
bjorn b70f8e2d1a Fix and separate ShaderBlock:send(Blob) offset arguments;
- You were able to write a Blob to a ShaderBlock
- Using ShaderBlock:send(Blob, offset, size)
- It was not flexible enough and it was broken
  - The data was read from `offset` bytes into the Blob.
  - The data was written to the beginning of the Buffer.
  - The Buffer was flushed at `offset` bytes into the Buffer.
- This commit changes the signature of the variant
- to ShaderBlock:send(Blob, srcOffset, dstOffset, size)
- and hopefully fixes the behavior.
- Also why is this entire commit description a bulleted list
2021-06-28 22:32:11 -07:00
bjorn 63320252a1 Fix error when rapidly recreating objects;
If you create and destroy objects quickly (using :release), malloc
might give you the same pointer.  When we look up this pointer in
the userdata cache, it'll give you an invalid Proxy/pointer, which
throws an error like "Calling 'fn' on bad self".

When collecting objects, remove them from the userdata cache.
2021-06-26 14:41:42 -07:00
bjorn f4ac1ef422 Minor unreachable fix;
Would like to keep unreachable throws consistent.
2021-06-24 14:47:48 -07:00
mcc caf9428ff1 Fix compile on macos 10.13 2021-06-24 15:47:30 -06:00
bjorn 4125796211 Fix shaders with nil stages;
The length was getting kept as zero, need to adjust length when
falling back to default shaders.
2021-06-21 10:22:15 -06:00
Jakob Bornecrantz 93d867a972 Fix AppImage lovr.desktop file
Changes by @darltrash
2021-06-18 15:53:31 -06:00
Jakob Bornecrantz 1842d9e6bb Fix AppImage lovr.desktop file
Changes by @darltrash
2021-06-18 15:53:13 -06:00
bjorn 92a08c326f vrapi: getViewPose returns a pose when position is invalid;
To match getViewAngles.  Also simplify mask check.
2021-06-18 15:51:18 -06:00
brainrom 59d3b25932 Able to get view angles with 3DOF 2021-06-18 15:50:28 -06:00
kokokoshka 7e52ffe956 MinGW support 2021-06-18 15:45:26 -06:00
bjorn 526e06d445 Fix mat4 corruption when using vectors;
We correct m[15] to 1.f too late, by that time the undefined 4th
component of the vec3 could have corrupted the rotation/scale.
2021-06-16 16:55:19 -06:00
bjorn 88000579ff Don't call start on tracking drivers;
Start is mainly used for setting up graphics-related stuff, since it
was created to perform setup after the window/graphics module is
initialized.  Since the display driver is the only one doing rendering,
it makes sense to only call start on the display driver.

...also fixes a bug where start is getting called twice.
2021-06-16 16:15:08 -06:00
bjorn 0582746137 Fix OpenXR compilation; 2021-06-12 14:42:30 -06:00
bjorn 82b7632cea Require material textures to be 2D; 2021-06-12 14:26:39 -06:00
bjorn 69a22afed4 Fix vrapi compilation; 2021-06-12 14:15:00 -06:00
bjorn 92400df89d lovr.headset.init -> lovr.headset.start;
- We need some headset initialization to happen upfront
- But we still want some delayed initialization for when graphics is ready
- Go back to headset initialization happening when module is required
- Add lovr.headset.start that can be used for post-graphics init
2021-06-10 17:26:15 -06:00
bjorn 7dc54cc264 Add lovrCheck macro;
lovrCheck is a new way of performing runtime assertions.

It's identical to lovrAssert, except it's compiled out if
LOVR_UNCHECKED is defined.

It is meant to be used for non-mission-critical validation, for
example proper usage of types passed to the Lua API.  lovrAssert
should still be used to check return values from platform APIs.
2021-06-05 11:12:00 -06:00
bjorn 053c318995 Fix depth test;
- Use incoming depth settings to determine whether depth test should be
  enabled or disabled (wtf)
- Always track state.depthTest, even if depth test is disabled
2021-06-01 12:58:02 -06:00
bjorn bf627e1e3e Allow passing vec2 as scale argument;
Useful for planes.
2021-06-01 09:59:38 -06:00
bjorn a9e22a37c2 rm unused variables; 2021-06-01 09:59:38 -06:00
bjorn 907305e430 Fix oculus hand model orientation;
- Previously, animate was converting from oculus basis to lovr basis.
- Not all hand models are animated.
- Instead, apply the compensation in newModel.
- This means that both animated and non-animated models have correct orientation.
- Verified that regular getPose is returning correct rotation as well.
2021-06-01 09:59:38 -06:00
Ilya Chelyadin ce3470a6e6 All-in-One Lua loader 2021-06-01 09:59:38 -06:00
bjorn a45fab4416 vrapi: map pinch to trigger axis; 2021-06-01 09:59:38 -06:00
bjorn ca4b7d01bc Allow passing vec2 as scale argument;
Useful for planes.
2021-05-31 15:05:13 -06:00
bjorn 46a5c83a08 rm unused variables; 2021-05-31 15:04:24 -06:00
bjorn 89550e55d6 Fix oculus hand model orientation;
- Previously, animate was converting from oculus basis to lovr basis.
- Not all hand models are animated.
- Instead, apply the compensation in newModel.
- This means that both animated and non-animated models have correct orientation.
- Verified that regular getPose is returning correct rotation as well.
2021-05-31 14:35:53 -06:00
Nevyn Bengtsson ff4f594a62 switch back from aaudio to opensl
because capture on quest is broken with miniaudio's aaudio backend :/
2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 28abb7270d Omit main() function if requested 2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 7b70fac0bb mic permissions code for macos 2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 9c37a6cdc8 don't include main/winmain in dll build
otherwise the parent app can't define a main of its own
2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 62a2d01daf API for Sound:getCapcity 2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 6566423f66 Sound:setFrames should use a stream's write buffer size, not read buffer size
otherwise you can never fill up a stream from scratch
2021-05-31 09:07:38 -06:00
Nevyn Bengtsson 9f45e7a9c5 I think audio:setDevice requires this permission 2021-05-31 09:07:38 -06:00
Ilya Chelyadin b6c3a8fa17 All-in-One Lua loader 2021-04-30 18:50:35 -06:00
bjorn 25bb12d07c Native textures don't destroy their handles;
If a Texture is created from a handle, that means someone else created
it, so we expect them to destroy it.  We were always destroying handles,
and I guess this was usually okay because glDeleteTextures is idempotent.

However, we're seeing a crash in the Oculus driver when OVR is torn
down.  Presumably it is trying to access its swapchain textures after we
destroyed them.  Not sure why this wasn't an observable issue before,
maybe it's a new regression.  Still, it makes sense to only delete the
GL texture handle if we were the one that created it.

We don't need to check this for the renderbuffer since we always own those.
2021-04-27 22:24:42 -06:00
bjorn 51f81c9db6 Switch back to ALSA on Linux; 2021-04-27 22:20:56 -06:00
bjorn 87bf9c7b27 Merge branch 'master' into dev 2021-04-27 22:20:38 -06:00
bjorn 4a4aff210d Upgrade miniaudio; 2021-04-27 22:17:07 -06:00
bjorn 0a9956db60 phonon: Fix crash when setGeometry fails;
The call to `free` above was fixed, but the one in the error case
was not.
2021-04-27 22:15:15 -06:00
bjorn 09c1fe8117 Improve luax_readmesh error handling; 2021-04-23 12:55:21 -06:00
bjorn 159243190b rm some unnecessary includes; 2021-04-20 20:08:30 -06:00
Jakob Bornecrantz 28a0356a9a Add overlay support for OpenXR 2021-04-16 14:20:05 -06:00
Jakob Bornecrantz 70ef04e595 Add overlay parameter to headset init 2021-04-16 14:20:05 -06:00
Jakob Bornecrantz 909b43f34a Order OpenXR extension adding 2021-04-16 14:20:05 -06:00
Josip Miskovic 8b5d3af9b8 Allow using alpha with hexcode when setting color
Implements #411 proposal
2021-04-15 10:24:35 -06:00
bjorn f2590078a9 Don't always force AMD mode to true!; 2021-04-14 10:41:14 -06:00
Jakob Bornecrantz b02c30a0e4 Make bin directory AppImage ready 2021-04-13 11:03:57 -06:00
bjorn 90b33572e1 Use WebGL buffer path on AMD GPUs;
AHHHHHHHHHHHHH
2021-04-13 10:52:28 -06:00
mcc d558996206 Hold lock when changing geometry (prevents crash, see issue #403) 2021-04-12 13:01:54 -06:00
bjorn fa47ecbdd3 v0.15.0; 2021-04-11 08:57:11 -06:00
bjorn 7b7c3132b8 vrapi: Fix lovr.headset.animate flipping left hand; 2021-04-11 08:15:17 -06:00
bjorn 70bbbc4549 Use pulseaudio on linux; 2021-04-11 07:19:49 -06:00
bjorn 046762c564 WebXR: Fix isDown; Fix hand tracking; 2021-04-10 19:41:37 -06:00
bjorn d2a9e230bf Rework Sound:getFrames;
It follows a more predictable argument order.

Fixed crash when reading frames into Blob.
2021-04-05 12:52:16 -06:00
bjorn 1ef99882f7 Fix Mesh vertex map memory leak; 2021-04-05 10:24:43 -06:00
bjorn f565a7b69b rm linking to OpenSLES; 2021-04-03 18:42:34 -06:00
bjorn df6b6516d6 Add required Oculus manifest entries; Add debuggable; 2021-04-03 18:42:34 -06:00
bjorn 3b61dfc8c9 miniaudio: Use AAudio instead of OpenSL; 2021-04-03 18:42:34 -06:00
bjorn 419f281291 rm oculus go support; add oculus quest 2 support;
Rest in pieces, oculus gone.
2021-04-03 18:42:34 -06:00
bjorn 5106aaf74c Audio listener/source default to identity orientations; 2021-04-03 18:38:27 -06:00
bjorn 2b94bcb46e Add quat_identity; 2021-04-03 18:38:23 -06:00
bjorn 609d7e05ce simple spatializer supports directivity;
Also coming soon to an oculus spatializer near you.
2021-04-03 18:22:23 -06:00
bjorn 19620c7682 wasm: Use default miniaudio buffer size.
Audio currently stutters on the wasm build.  It is much more severe
in Chrome than in Firefox (very rare/subtle in Firefox).  miniaudio
is currently using ScriptProcessorNode, which is deprecated because
it processes audio on the main thread.  There's a new API that lets
you programmatically process audio on a thread called AudioWorklet,
but it's hella complicated.  miniaudio doesn't want to support this
because it's complicated and requires a separate JavaScript request
but it seems like it would be possible to work around using a Blob.
In the meantime, miniaudio bumps up the buffer size on WebAudio, so
let's just use that in hope that it helps.
2021-04-03 18:04:26 -06:00
bjorn efa48bda70 Manually disable a few miniaudio features; 2021-04-03 13:57:13 -06:00
bjorn d32d9f6d67 Source directivity power defaults to 1; 2021-04-03 11:22:23 -06:00
bjorn 15975343ea Sound:get/setFrames respects channel count; 2021-04-03 10:28:03 -06:00
bjorn 024498b964 Source:clone fixes;
Clones no longer try to create converters if they aren't needed, which
was causing an error.

Also handle malloc failure.
2021-04-03 09:49:27 -06:00
bjorn 4469fc99e8 Fix mixer bug; Refactor mixer;
- Sources without converters always read into the beginning of the
  raw buffer, overwriting previous frames if the source was rewound
  due to looping.  This resulted in an audible click whenever the
  source was rewound.
- After looping, Sources without converters would try to read too
  many frames -- they would read a full buffer instead of only the
  necessary number of frames.
2021-04-02 23:36:30 -06:00
bjorn 69b5c51388 Fix Sound:setFrames; 2021-04-02 23:35:18 -06:00
bjorn 6f6e7eea1b Better newSound error messages; 2021-04-02 23:35:18 -06:00
bjorn 6ae0d9f96a phonon works by default when no mesh is provided; 2021-04-02 23:35:18 -06:00
mcc 6b099e467f Encapsulate "uses spatializer?" nature in lovrSourceUsesSpatializer
Also, remove accessor prototype for old IsSpatial() function
2021-04-02 14:16:39 -06:00
bjorn 0021c70f9f luax_readmesh supports nested tables; 2021-04-01 18:48:37 -06:00
bjorn 82a309a56d Draft new effects API;
- A list or map of effects can be provided to newSource.
- false can be used to bypass effects.
- All effects are enabled by default.
  - Occlusion-y effects should only take effect when setGeometry is called
    - Spatializer is responsible for ensuring this.
2021-04-01 16:46:16 -06:00
bjorn 923498a927 webxr: also support velocity of head device; 2021-03-31 22:47:26 -06:00
bjorn 72403de209 webxr: Add support for lovr.headset.getVelocity; 2021-03-31 22:37:29 -06:00
bjorn 35032bb21c Upgrade miniaudio; 2021-03-31 22:32:16 -06:00
bjorn 441039db19 miniadio: Enable WebAudio backend; 2021-03-31 14:30:06 -06:00
bjorn cfe0d71520 audio: throw if miniaudio fails to initialize;
This prevents a situation where miniaudio fails to initialize but the
audio module is still usable.
2021-03-31 14:01:30 -06:00
bjorn 0ef48d3d26 os_web: fix mouse support;
Not sure why this got removed.
2021-03-31 11:24:52 -06:00
bjorn 4a2c315bdb Fix luax_readmesh with Model; 2021-03-30 12:48:18 -06:00
bjorn eb8b559e88 phonon: Fix freeing incorrect variable; 2021-03-30 12:45:24 -06:00
Josip Miskovic f6fbc2ad17 Route ODE messages into LOVR log system
ODE errors, debugs and messages are redirected into LOVR's log system
by a callback mechanism for each.

The ODE submodule is updated to revision that does not crash when error
or debug occurs.
2021-03-28 17:34:11 -06:00
bjorn 0daaca7a4f Merge branch 'master' into dev 2021-03-28 10:09:58 -06:00
bjorn e346c3f807 Fix standard shader precision issues;
- Reduce epsilon
- Also use epsilon in D_GGX
- Reduce shader string length to the minimum required supported length
2021-03-28 10:08:10 -06:00
bjorn 2b1b777e84 Fix crash when passing nothing to newTexture; 2021-03-26 20:02:38 -06:00
bjorn 948b77b7fa phonon doesn't try to make a mesh if there are no vertices; 2021-03-26 10:30:08 -06:00
bjorn 0dfc80e42e luax_readmesh assert for index range; 2021-03-26 10:23:24 -06:00
bjorn 61ef2747ee World:newMeshCollider uses luax_readmesh;
This is a breaking API change -- instead of a table of tables, a flat
table of coordinates must be used.
2021-03-25 12:29:11 -06:00
bjorn 6413a6eda2 Fix Model:getTriangles; Add Lua API; 2021-03-25 12:29:11 -06:00
bjorn fe0eedea20 luax_readtriangles -> luax_readmesh; Model support; 2021-03-25 12:29:11 -06:00
bjorn e1195a92a0 lovrModelGetTriangles; 2021-03-25 12:29:11 -06:00
bjorn 3a35f81918 Fix underscores not printing;
Signed arithmetic strikes again.  Before the padding was configurable,
padding was just a #define'd constant, so signedness didn't matter.
2021-03-25 12:18:48 -06:00
bjorn 895589c914 Add even more padding to stb zlib; 2021-03-24 21:13:04 -06:00
bjorn fd39ed9420 os_android: fix improper cast; 2021-03-24 14:32:56 -06:00
bjorn 634e7210bf Make Source:clone suck less; 2021-03-23 14:31:04 -06:00
bjorn 5ef5ac5f22 I am once again fixing the mixer EOF case; 2021-03-23 14:31:04 -06:00
bjorn 6a79ffb34a rm Source::blend; 2021-03-23 14:31:04 -06:00
bjorn de5099badd rm SourceInterpolation; 2021-03-23 14:31:04 -06:00
bjorn 98f33dc131 mv falloff attenuation; 2021-03-23 14:31:04 -06:00
mcc e3c2b5b865 Fix Android build
- Fix typos after refactor
- Fix CMake when using ANDROID_PACKAGE
2021-03-22 14:09:16 -06:00
bjorn a1f768e1a3 lovr.audio.stop properly returns success; 2021-03-20 11:57:46 -06:00
bjorn b1f7a6c11d Add optional VolumeUnit to get/setVolume functions;
Volume can be specified in linear units or dB.
2021-03-19 17:20:48 -06:00
bjorn c1c15c46db Don't share ma_data_converters between Sources;
It causes distortions when resampling is involved.
2021-03-18 16:31:14 -06:00
bjorn 96e0cc8b9b Fix mixer bug when reaching end of source; 2021-03-18 13:47:04 -06:00
bjorn 369bd5d8b4 Clamp source/listener volumes to 0-1 range;
Prevents miniaudio errors and horrible clipping on bad input.
2021-03-18 13:06:11 -06:00
bjorn e677006581 newSource: typecheck second arg;
Errors when using old syntax instead of silently working/failing
2021-03-18 13:00:23 -06:00
bjorn e008dd2323 Fix stb_vorbis bug with empty comment list files; 2021-03-18 12:43:36 -06:00
bjorn 0bb556554d Probably work around stb_image bug that breaks zips;
30e01f upgraded stb_image to include its 95560b commit from its #960
pull request.  This made stb_image fail more aggressively on EOF
conditions when refilling huffman buffers in deflate streams.  I think
it might be failing _too_ aggressively, though.  We are able to pad our
input compressed buffers since the zip file format is guaranteed to have
extra data at the end (for, e.g., the end of central directory record).
This appears to be sufficient to fix compressed zip archives for the
time being.  It's possible that more virtual padding needs to be added,
and it may be good to try to fix this in stb_image itself.
2021-03-18 00:05:34 -06:00
bjorn 2d43620d3c rm LOVR_ALIGN;
It isn't very portable, the effects aren't significant.
2021-03-15 18:56:02 -06:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn f9f4907a50 phonon fixes; 2021-03-07 22:42:54 -07:00
bjorn 45e43bacb3 os_web fixes; 2021-03-07 22:04:23 -07:00
bjorn 0435694225 simple spatializer interpolation;
prevents snaps, crackles, and pops
2021-03-07 21:19:25 -07:00
bjorn 30a0556f1d Fix oculus spatializer; 2021-03-07 21:19:24 -07:00
bjorn deb756392b Fix 'attempt to flush unmapped buffer' when creating empty Mesh; 2021-03-07 21:19:24 -07:00
bjorn a3b791a7e7 Fix Canvas flushing; 2021-03-07 21:19:24 -07:00
mcc 9f0826e3b7 Add missing header in headset_oculus, this fixes a warning. 2021-03-05 15:07:18 -08:00
mcc 4bed6f6834 Fix crash on startup on Oculus driver 2021-03-05 15:07:18 -08:00
bjorn 6de00cf2b8 crush ico; 2021-03-04 19:24:33 -07:00
bjorn 058700f970 Allow lovr.audio.setDevice(type, nil); 2021-03-04 18:19:05 -07:00
bjorn 0c3351331e Sink attempt; 2021-03-03 20:01:56 -07:00
bjorn f806c07bfa Simplify spatializer interface temporarily; 2021-03-03 15:49:28 -07:00
bjorn bc41eecf09 oculus spatializer: free memory; use MAX_SOURCES 2021-03-03 15:46:01 -07:00
bjorn 8188e51060 lovr.audio.get/setAbsorption;
I HOPE THIS LETS US DO UNDERWATER EFFECT
2021-03-03 15:40:27 -07:00
bjorn 2c0875087f Source:getSound; 2021-03-03 15:32:41 -07:00
bjorn dd98b11b3f Effect;
Basically replace each individual accessor with a general one.
2021-03-03 15:25:03 -07:00
bjorn 746735259c Windows: Always use WinMain for UTF8 command line arguments;
This fixes problems with paths containing special characters on windows.
2021-03-02 11:49:08 -07:00
bjorn dd0891d087 Fix simple spatializer; 2021-03-02 11:49:00 -07:00
bjorn e1e21def82 More consistent spatializer symbol names; 2021-03-01 17:53:49 -07:00
bjorn 1c3a01de2a Add windows icon; 2021-03-01 17:45:12 -07:00
bjorn bb302c3336 Fix OpenXR hand tracking on Quest; 2021-03-01 11:55:27 -07:00
bjorn cf4bb36d03 AudioMaterial; 2021-02-28 15:27:33 -07:00
mcc d233d5ccd3 Fix MSVC build
- stdatomic.h had not defined ATOMIC_INT_LOCK_FREE, but it is now required
- It's _MSC_VER, not _MSVC_VER
2021-02-28 14:12:16 -08:00
bjorn 5f4e5c5721 rm Source:play loop shortcut; 2021-02-26 13:41:58 -07:00
bjorn 92492dcef1 rm spatial blend for now; 2021-02-26 13:24:01 -07:00
bjorn cb1b78f2cc Rename Source:get/setTime to Source:seek and Source:tell; 2021-02-26 13:21:40 -07:00
bjorn 7bb6861180 Source:get/setPosition; Source:get/setOrientation; 2021-02-26 13:10:59 -07:00
bjorn f3482fc15a lovr.audio.get/setPosition; lovr.audio.get/setOrientation; 2021-02-26 13:05:23 -07:00
bjorn d1a2ded4db Fix luaopen_lovr_filesystem stack index; 2021-02-25 16:29:52 -07:00
bjorn f82e8112fe Simplify filesystem arguments; 2021-02-25 10:45:45 -07:00
bjorn a09b7de545 lovr.system.getCoreCount; 2021-02-25 09:30:05 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn a94a1c22bf simple spatializer uses physically correct attenuation;
This matches phonon.
2021-02-24 17:51:44 -07:00
bjorn 39a4d2c1d5 rm lovr.graphics.triangle; 2021-02-24 17:45:31 -07:00
bjorn 3055cd718c rm shared sources; 2021-02-24 17:43:42 -07:00
bjorn f47a688d53 phonon: configuration options; 2021-02-24 17:43:42 -07:00