1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-05 22:03:36 +00:00
Commit graph

1964 commits

Author SHA1 Message Date
bjorn 70dc871f88 More work on Animator; 2019-02-13 15:10:52 -08:00
bjorn 40b8b8da7c Fix primitive restart overflow for u32 indices; 2019-02-13 15:10:52 -08:00
bjorn d14af4a79c Fix traversal; 2019-02-13 15:10:52 -08:00
bjorn 67f4aa0cb4 Fix samplers; 2019-02-13 15:10:52 -08:00
bjorn ef12cdf3c2 Fix size calculation; 2019-02-13 15:10:52 -08:00
bjorn 1426b368b8 WIP; 2019-02-13 15:10:52 -08:00
bjorn 80b584aeb5 Compute global transforms better; 2019-02-13 15:10:52 -08:00
bjorn 80bb75968e WIP animator rewrite; 2019-02-13 15:10:52 -08:00
bjorn 2692abb83c Render nodes properly; 2019-02-13 15:10:52 -08:00
bjorn b1b6ec0f6d Parsing improvements; 2019-02-13 15:10:52 -08:00
bjorn e8a2ac8063 Parse materials; 2019-02-13 15:10:52 -08:00
bjorn c66a7468bb Parse textures; 2019-02-13 15:10:52 -08:00
bjorn 39ce68f2be Parse samplers; 2019-02-13 15:10:52 -08:00
bjorn 92aa1a234b Parse images; 2019-02-13 15:10:52 -08:00
bjorn 4ed3cad851 Parse animations; 2019-02-13 15:10:52 -08:00
bjorn 6b323e3476 Start parsing glTF; 2019-02-13 15:10:52 -08:00
bjorn 50e86579c2 vec3:min; vec3:max; 2019-02-08 12:39:10 -08:00
mcc 41e621d006 Back out state.offset change in oculus
This makes rendering work correctly again, but now most likely state.offset does not work right.
2019-02-08 15:00:50 -05:00
mcc 6c152a5fc6 Fix Oculus driver compilation (still renders wrong) 2019-02-08 14:42:13 -05:00
bjorn f34e6f86ea Fix DepthFormat constant in oculus backend; 2019-02-08 10:57:35 -08:00
bjorn f53f64933c WebGL fixes; 2019-02-08 10:32:05 -08:00
bjorn 3c83b36845 LuaJIT: Add .name metafields for compatibility; 2019-02-08 08:13:47 -08:00
bjorn 4a25a0120f Vector rework; 2019-02-08 08:13:47 -08:00
bjorn 3c08cfb278 Remove gl_FragCoord from fragment shader header;
This fixes a problem where shader compilers are complaining about
the "extension" declarations coming after the "in" declaration.
2019-02-08 07:15:20 -08:00
bjorn d12d185e6c Fix lovr.graphics.getPixelDensity when widths are zero; 2019-02-07 14:49:49 -08:00
bjorn 6f20126020 Fix bug with mesh divisors; 2019-02-05 15:57:22 -08:00
bjorn 0d81745282 Fix error screen; 2019-02-05 13:15:27 -08:00
bjorn dc7f9cd0d5 lovr.graphics.getPixelDensity; 2019-02-05 12:46:48 -08:00
bjorn f0a975b522 lovrGraphicsGetPixelDensity; 2019-02-05 12:46:48 -08:00
bjorn 17641fb7f0 Platform window functions accept NULL pointers; 2019-02-05 12:46:48 -08:00
bjorn 8e942561f1 Simplify CompareMode handling; 2019-02-01 15:10:12 -08:00
bjorn 85ab7c7c6e Fix comment typo; 2019-02-01 14:44:13 -08:00
mcc 4859360209 Fix compile with -DLOVR_ENABLE_HEADSET=NO 2019-02-01 13:20:28 -08:00
bjorn a2cceb0b56 Fix bad interaction between vaos and ibos; 2019-01-31 17:24:13 -08:00
bjorn 86977bd7bd Don't use autoinstancing for stream batches; 2019-01-31 17:23:49 -08:00
bjorn eae3669fea Rebuild math.lua.h; 2019-01-31 13:54:54 -08:00
bjorn a1361fcd41 mat4:unpack accepts raw flag; rm redundant functions; 2019-01-30 16:18:08 -08:00
bjorn 0eb2789a2d Improve mat4:set;
Ended up removing the diagonal variant, sorry holo.
2019-01-30 16:13:44 -08:00
bjorn 3d4cb166bc Add quat:length; 2019-01-30 00:56:57 -08:00
bjorn 3b000e64a1 Call the proper GLES2Loader in GLES; 2019-01-29 22:04:15 -08:00
bjorn b78e7a15bb Add OpenGL ES support to glad header; 2019-01-29 22:04:15 -08:00
bjorn bf89216997 Explicitly convert lua_Numbers to floats; 2019-01-29 22:04:04 -08:00
bjorn 03e3e14718 Font:setFlipEnabled; Font:isFlipEnabled; 2019-01-29 21:49:49 -08:00
bjorn f5a903a805 Oops, use calloc in _lovrAlloc; 2019-01-29 20:08:10 -08:00
bjorn 3aec7f7767 Fix struct definition in UBO;
You can't define a new struct in an interface block.
2019-01-29 19:57:18 -08:00
bjorn 6291a5ad5a Always check malloc result; Less calloc;
Some more questions:

- Should there be some kind of allocation helper so you don't need
  to always check the result?
- Throwing an error on OOM is convenient and is probably correct 90%
  of the time, it even provides a nice error message instead of a
  nil dereference somewhere.  But it's inflexible.  Is it the right
  thing to do?
2019-01-29 16:53:01 -08:00
bjorn 5d29ec2db1 Curve supports vec3; 2019-01-29 16:33:44 -08:00
bjorn a878139e26 rm math out args;
Needs more consideration before it can be added at the desired quality level.
2019-01-29 16:05:48 -08:00
bjorn 6c5ceabe02 Fix quat:set(nil) in vanillua; 2019-01-29 16:05:48 -08:00
bjorn dac289d624 mat4:__mul works with vec3 in vanillua; 2019-01-29 16:05:48 -08:00
bjorn 9839277e8d Fix quat:mul edge case; 2019-01-29 16:05:48 -08:00
bjorn c08cb664e7 mat4:mul; 2019-01-29 16:05:48 -08:00
bjorn 30acdd1347 Add semantic GL defines; 2019-01-29 16:05:27 -08:00
bjorn 6be9bf4911 Fix primitive restart on GLES; 2019-01-29 16:05:27 -08:00
bjorn 6c961bb404 rm math copy functions;
They are redundant.
2019-01-29 03:57:11 -08:00
bjorn 1bd58d6cef Rebuild boot.lua; 2019-01-29 02:07:34 -08:00
bjorn b37fc5dbbe Remove fixed-function mirroring code from headset drivers; 2019-01-28 18:29:50 -08:00
bjorn f2cb7e7e3d Reset color to white after drawing nogame screen; 2019-01-28 18:21:46 -08:00
mcc b09c3adeec Fixes to lovr.mirror() requested in PR 2019-01-28 15:03:58 -08:00
mcc aab1bda92d Implementation of getMirrorTexture() 2019-01-28 15:03:58 -08:00
mcc 95fcc3eb0b Attempt to make a lovr.mirror() for Window purposes as discussed in chat.
Adds lovr.graphics.hasWindow()
2019-01-28 15:03:58 -08:00
bjorn b410227990 Font:getRasterizer; Font:setPixelDensity(nil); 2019-01-25 12:54:11 -08:00
bjorn 6fd4b9ef4c Header cleanup; 2019-01-24 17:43:25 -08:00
bjorn 5770b63108 Revert "Add stb_sprintf;"
This reverts commit da565296fd.
2019-01-24 17:40:22 -08:00
bjorn cb9f166234 Revert "Replace sprintf with stb version;"
This reverts commit 8f9d24c51f.
2019-01-24 17:39:27 -08:00
bjorn bf19fd5c15 Avoid more implicit float-double conversions; 2019-01-24 17:00:41 -08:00
bjorn bda248b86e Be more intentional about doubles vs. floats; 2019-01-24 16:48:06 -08:00
bjorn bec98004ff Fix vertical text align;
Off-by-one error with counting lines.
2019-01-24 14:07:02 -08:00
bjorn c473bf50e8 Buffers individually keep track of their flush range;
Fixes bugs with attached Mesh attributes, where flushing wasn't
happening when it should have.
2019-01-22 12:11:01 -08:00
bjorn 25606738c5 rm Curve:getDegree; 2019-01-21 09:49:07 -08:00
bjorn eeecd65029 Update Curve error messages; 2019-01-20 20:40:40 -08:00
bjorn 8e0ccbf09a Curve:split -> Curve:slice; 2019-01-20 20:36:42 -08:00
bjorn 5deae0a103 Rename setWindow back to createWindow;
I'm not sure why this was changed.  It doesn't make very much sense
because setWindow can't be called multiple times, and it can't be
called with nil/NULL.
2019-01-20 20:06:40 -08:00
bjorn 8f9d24c51f Replace sprintf with stb version; 2019-01-18 08:55:29 -08:00
bjorn da565296fd Add stb_sprintf; 2019-01-18 08:55:29 -08:00
bjorn 347a399890 Adjust util.h macros; 2019-01-18 08:44:03 -08:00
bjorn e6d9b82bba Adjust BlockType; getValue -> read; 2019-01-16 10:02:44 -08:00
bjorn ee7544eba8 ShaderBlock:getValue; Shader:send vector fixes;
Allows you to read back values from a ShaderBlock.

- This is also probably useful for Shaders.
- This creates SO MANY tables.  It feels so bad to expose this.  But
  also it's the only way to read values back from a compute operation,
  so it's pretty indispensable.  In the future there could be a Blob
  variant.
2019-01-16 10:02:44 -08:00
bjorn 3d2488a577 I forgot DRAW_ID and VERTEX need the same counts; 2019-01-15 19:43:11 -08:00
mcc d8147dd67d Small portability compile fixes in headers 2019-01-14 13:17:40 -08:00
bjorn 27000d2238 Rebuild math.lua.h; 2019-01-14 12:30:47 -08:00
bjorn 5ac3c51607 Fix shifting precedence; 2019-01-14 12:29:25 -08:00
bjorn aa56cbc7b0 Fix crash on repeated calls to Channel:peek; 2019-01-12 20:51:50 -08:00
bjorn 5382bc3379 Fix some batching edge cases;
- Reduce size of vertex buffer by one to account for primitive restart.
- Always write to the draw ID buffer to prevent it from going out of sync with the vertex buffer and prevent a potential problem with geometry reuse.
2019-01-12 18:25:38 -08:00
bjorn bb9d354ac9 Fix missing LuaJIT return; 2019-01-12 05:06:57 -08:00
bjorn 6bfc6623ac More consistent matrix out args; 2019-01-12 04:58:05 -08:00
bjorn 577ed57b2d oops, access the two types of Pools properly; 2019-01-12 04:22:11 -08:00
bjorn c41a5c4e3c Math copy functions allow you to specify a Pool; 2019-01-12 03:46:14 -08:00
bjorn 990544d3f4 Fix quat:save in LuaJIT; 2019-01-12 03:06:40 -08:00
bjorn 90cacd03ca Handle numbers more consistently in Lua API;
I still don't know if I should cast or not, but at least now things
will be consistently right or wrong.
2019-01-11 22:37:54 -08:00
bjorn 538f5f8aa1 Trim stbtt;
Removes functionality from stb_truetype that isn't being used.
This makes it compile 25% faster (~.5s).
2019-01-11 14:01:55 -08:00
bjorn c85fd69079 Optimize uniform parsing;
By only parsing the first uniform in an array.
2019-01-11 12:27:40 -08:00
bjorn 305acb89a9 Fix quaternion multiplication signs; 2019-01-11 05:35:08 -08:00
bjorn 7338c82d7f Add resizable vector pools;
It seems too dangerous/annoying to have pools error when they run
out of memory.  Instead, we'll make it so you can choose to make
a pool resizable, where it enlarges its memory if it runs out. By
default Pools aren't resizable, but the default math pool is.

Also, reduce the size of the default pool from 640k to 4k.
2019-01-10 14:10:04 -08:00
bjorn f709a6849b Fix crashes with :save'd vectors in LuaJIT; 2019-01-08 02:37:50 -08:00
bjorn dee53f953c Fix vector save functions in LuaJIT; 2019-01-08 00:54:07 -08:00
bjorn 40c7deaefe Vector API improvements; 2019-01-06 03:25:00 -08:00
bjorn c7fa8f8497 Fix vec3:set; 2019-01-05 00:21:56 -08:00
bjorn 49b0aaa986 Pool allocation failures throw an error;
For now.
2019-01-05 00:11:23 -08:00
bjorn cc88a0b919 Expose option to flip TextureData on load; 2019-01-04 23:32:25 -08:00
bjorn ed71485fcc Fix header vs. implementation pool function names; 2019-01-04 23:32:25 -08:00
bjorn e1c656c288 Primitive restart is automatic in WebGL; 2019-01-04 18:01:01 -08:00
bjorn 83a56efd5e Ugh; 2019-01-04 18:01:01 -08:00
bjorn fc08b479dc Fix sign issue; 2019-01-04 18:01:01 -08:00
bjorn dac6b0fdbb Cache geometry; 2019-01-04 18:01:01 -08:00
bjorn ea13e638c2 Fix viewports; 2019-01-04 18:01:01 -08:00
bjorn 379dc74cd5 Mesh fixes; 2019-01-04 18:01:01 -08:00
bjorn 6f96ee65da Finish primitive restart; 2019-01-04 18:01:01 -08:00
bjorn 67727b092b Start primitive restart; 2019-01-04 18:01:01 -08:00
bjorn 6382c1f71c Cleanup; 2019-01-04 18:01:01 -08:00
bjorn 1068dd1081 Rework cylinder; 2019-01-04 18:01:01 -08:00
bjorn ea3a77a73a Many batching improvements; Refactoring; 2019-01-04 18:01:01 -08:00
bjorn d66057ee70 Avoid redundant strlen in font printing; 2019-01-04 18:01:01 -08:00
bjorn fae7786c8d Simplify Pipeline; 2019-01-04 18:01:01 -08:00
bjorn 1c5d73e3da Make more GPU functions static; 2019-01-04 18:01:01 -08:00
bjorn ffd7a1202c rm lovrCanvasIsDirty; 2019-01-04 18:01:01 -08:00
bjorn 709a91ac56 rm Shader.dirty; 2019-01-04 18:01:01 -08:00
bjorn 09832dab8f rm Mesh.dirty; 2019-01-04 18:01:01 -08:00
bjorn 111cfafaf2 rm lovrMeshDraw; 2019-01-04 18:01:01 -08:00
bjorn c87645e8ef Put non-opengl-specific stuff in their own files; 2019-01-04 18:01:01 -08:00
bjorn fbcee9ac9c rm lovrTextureGetId; 2019-01-04 18:01:01 -08:00
bjorn 55e889824f lovrGpuSubmit; 2019-01-04 18:01:01 -08:00
bjorn 62645cde28 Pipeline -> 4 bytes; lineWidth -> uint8_t; 2019-01-04 18:01:01 -08:00
bjorn 561805450d rm Pipeline.dirty; 2019-01-04 18:01:01 -08:00
bjorn 498c25a544 Move Shader out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn c99527ec2e Move pointSize out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn 9f79dd95f4 Move font out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn 29748dc0db Move color out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn dffcc8c295 Move Canvas out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn 030c765c6b Move backgroundColor out of Pipeline; 2019-01-04 18:01:01 -08:00
bjorn 2ceb474b04 DrawCommand -> DrawRequest; 2019-01-04 18:01:01 -08:00
bjorn 779e28353d Rebuild math.lua.h; 2019-01-04 02:19:10 -08:00
bjorn 4f716499b0 Fix declspec for math functions;
LuaJIT can't find math functions on windows unless they are exported.
2019-01-04 02:18:21 -08:00
bjorn 355aa9612c Fix redundant lovrAudio initialization; 2018-12-19 02:43:10 -08:00
bjorn 551bf12edd Minor cleanup; 2018-12-19 02:03:24 -08:00
bjorn eca8a71c84 Allocate files on the stack when possible; 2018-12-19 01:49:15 -08:00
bjorn 086f7f4e47 lovrRelease frees objects instead of destructor;
That way objects allocated on the stack can be destroyed.
2018-12-19 01:41:01 -08:00
bjorn 5b52a91778 mv ref->free ref->destructor; 2018-12-19 01:33:47 -08:00
bjorn 4c9b02a6ff Release builtin ShaderBlock; 2018-12-19 01:32:54 -08:00
bjorn 9803e9916f Use naming convention for destructor; 2018-12-19 01:04:42 -08:00
bjorn 155a0c1449 lovr*Create -> lovr*Init; lovr*Create macro; 2018-12-19 01:04:42 -08:00
bjorn 60a12a6b7e Rename thread module init/destroy; 2018-12-19 01:04:42 -08:00
bjorn c63c49338a Make opengl graphics structs more accessible; 2018-12-19 01:04:42 -08:00
bjorn 58950aa20e _lovrAlloc throws on OOM; 2018-12-19 01:04:42 -08:00
bjorn ab8e86b9a5 Fix vec3() in LuaJIT; 2018-12-17 20:14:10 -08:00
bjorn 68a0bf4a10 mat4:transformPoint; 2018-12-17 20:07:19 -08:00
bjorn b0a146919f Add vec3:length; 2018-12-17 19:32:43 -08:00
bjorn 25b47e62a8 rm Material isDefault; 2018-12-17 14:16:48 -08:00
bjorn 1fb2d6be02 Always use pushliteral when possible; 2018-12-15 21:45:32 -08:00
bjorn ad10f3bc37 Fix rgb10a2 constant; 2018-12-15 17:35:57 -08:00
bjorn 63f4fa261b Flush before Canvas resolve; 2018-12-14 16:02:30 -08:00
bjorn e6b7c41860 Improve lovrDrawData uniform names; 2018-12-14 16:02:25 -08:00
bjorn 28a53e8df5 Sort uniforms in ShaderBlocks; 2018-12-14 16:02:21 -08:00
bjorn 6dae6ecd07 Remove unnecessary breaks in lovrShaderCreateDefault; 2018-12-14 16:02:18 -08:00
bjorn b34ed206e0 Fix lovrBufferDestroy when Buffer is persistent; 2018-12-14 16:02:11 -08:00
bjorn 762cc64e09 Fix OpenVR events;
There was a problem where we were relying on module initialization ordering.  Now that modules are initialized in an arbitrary order, we can't guarantee that event will be loaded before headset.
2018-12-14 14:42:35 -08:00
bjorn 3972ddc2ad rm Cabin; 2018-12-14 10:58:03 -08:00
bjorn 099cf4cb22 Add VarelaRound; 2018-12-14 10:58:03 -08:00
bjorn 68a69eec2b Fix sphere and cylinder; 2018-12-13 23:05:56 -08:00
bjorn ff581d2e07 Fix Mesh:draw; 2018-12-12 19:39:01 -08:00
bjorn c999f10039 Use _Noreturn for lovrThrow;
Generates smaller and prettier assembly.
2018-12-12 19:35:18 -08:00
bjorn a67f59000f DrawMode -> DrawStyle; MeshDrawMode -> DrawMode;
Renaming enums doesn't really have an impact on the API usage, just
the docs and internal naming of things.
2018-12-12 18:43:04 -08:00
bjorn c3dcf03194 Minor param fix; 2018-12-11 22:54:13 -08:00
bjorn 2540953422 lovr.graphics.setAlphaSampling for alpha to coverage; 2018-12-11 22:52:58 -08:00
bjorn 28ab5377c8 Fix Mesh batching stuff; 2018-12-11 22:23:38 -08:00
bjorn 2435108d4d rm drawInstanced (last argument of draw instead);
Willing to revert this, but I think this is the cleaner API to use.
2018-12-11 22:16:40 -08:00
bjorn 259dbd5758 completely rm lovrGraphics from opengl.c; 2018-12-11 22:12:19 -08:00
bjorn b02eae30b4 Autoinstancing; 2018-12-11 22:10:29 -08:00
bjorn 18fdd0c062 Autobatching; 2018-12-11 13:27:59 -08:00
bjorn 387a91d5e4 lovr.graphics.flush; 2018-12-11 11:13:46 -08:00
bjorn 2e5c927b92 Expose max UBO size in lovr.graphics.getSystemLimits; 2018-12-11 11:13:02 -08:00
bjorn c531852932 Refactor rendering; 2018-12-10 23:05:02 -08:00
bjorn aa2f8867ee Mesh: more flexible int attributes;
This is ugh but be patient.
2018-12-10 16:00:37 -08:00
bjorn eaf26ce4b8 Struct cleanup; 2018-12-10 15:18:42 -08:00
bjorn 24ba340929 Add CHECK_SIZEOF;
It can be used to check the size of a type at compile time.
2018-12-09 23:36:02 -08:00
bjorn 7f333ce956 Refactor Mesh attributes; 2018-12-07 19:11:14 -08:00
bjorn 40454d1380 Use ShaderBlock for transforms/colors; 2018-12-07 18:19:03 -08:00
bjorn e2886d3bb5 Mesh uses Buffer; 2018-12-07 15:57:45 -08:00
bjorn 9a0f7c919a ShaderBlocks use Buffers; 2018-12-06 16:34:14 -08:00
bjorn ac33b8b085 Add Buffer objects; 2018-12-06 16:14:30 -08:00
bjorn b586bc2cce lovrFontRender uses raw float* instead of VertexPointer; 2018-12-05 10:23:26 -08:00
bjorn a8361677f5 Move pose from Mesh to DrawCommand; 2018-12-05 10:22:12 -08:00
bjorn 0a6de472ae Add ARB_buffer_storage; 2018-12-05 10:19:24 -08:00
mcc 4238402ec0 lovrFileWrite buffer can be const and therefore should 2018-12-04 12:40:30 -08:00
bjorn 3a774354e8 Remove lovrHeadsetGetEyePose;
A lot of drivers didn't bother to support it, it's not used very often,
and there are better ways to expose it that will soon be implemented.
2018-12-02 13:27:55 -08:00
bjorn 9a3ba5fb52 LuaJIT: mat4:scale accepts single number; 2018-12-02 13:03:29 -08:00
bjorn 9d965e1d7a LuaJIT: mat4:translate, rotate, scale support chaining; 2018-12-02 13:02:10 -08:00
bjorn 0054c771b2 Properly release Curves on creation; 2018-12-02 12:51:20 -08:00
bjorn fb455a671c LuaJIT: dereference vector pointers before use;
That way __sub doesn't break due to built-in pointer operator.
2018-12-02 12:48:44 -08:00
bjorn 4e6bf41e67 mat4 fixes; 2018-12-02 12:08:07 -08:00
bjorn ecabec9bf2 Finish LuaJIT API; 2018-12-02 12:08:07 -08:00
bjorn 43567e561a Update lovr.graphics.points/lines to work with vectors; 2018-12-02 12:08:07 -08:00
bjorn 2aadc9bde1 rm Transform; 2018-12-02 12:08:07 -08:00
bjorn c7934b3b13 Update API to work with vectors; 2018-12-02 12:08:07 -08:00
bjorn ba192374dc Start math types; 2018-12-02 12:08:07 -08:00
mcc ca75cb37c1 Awkward hotfix to tinycthread.h
Becuase of https://github.com/tinycthread/tinycthread/issues/47 . Only needed on Android. Not needed in the glfw tinycthread because we don't use glfw on Android.
2018-11-30 13:00:28 -08:00
bjorn 783115c2cf Add newlines to the end of some files; 2018-11-27 15:03:52 -08:00
mcc 778b654f1d Move lovr.android.getApplicationId() to lovr.filesystem.getApplicationId(). Kill Android module
This requires adding an application id function to platform and adding a mini definition to sds into platform.h. All platforms except Android return NULL (no application id)
2018-11-27 15:02:25 -08:00
mcc 264db37ce6 Fix lovr.event.quit("restart") on Android 2018-11-27 15:02:25 -08:00
mcc adabf4c6ef Fix broken android lua module
The LOVR_ENABLE_ANDROID flag wasn't getting passed to C, and the getApplicationId code had bugs
2018-11-27 15:02:25 -08:00
mcc 99026af5ca Fix Android compile 2018-11-27 15:02:25 -08:00
mcc 961bf859f6 Android lua module
Currently provides only a lovr.android.getApplicationId(). This returns an Android-specific identifier that doesn't cleanly map to anything specific in other OSes.
2018-11-27 15:02:25 -08:00
mcc 8e8091ccbc Fixes to error handling in boot.lua
- The pcalls to run conf were triggering their error very late, and were detecting error based on the second return value of pcall being non-nil. In fact the second return value of pcall is often non-nil in the case of *success*. We should check the first parameter, success/failure, instead.

- It is possible in principle to call error() with a non-string value, so errhand should sanitize its values with tostring.

- There is a check in the main boot.lua loop whether xpcall returned a string, which is the sign luajit hit an error in an error handler. This check was occurring in the wrong place (my fault; merge error when preparing PR) so if lovr.load() hit this case we were falling back to the horrible “could not call a string” error.
2018-11-24 18:48:29 -08:00
bjorn 0e99d47394 Fix module destruction;
There is a problem when a Thread stops: it destroys all of the modules
that it required.  This is because we unconditionally call luax_atexit
when modules are required, and when the thread lua_State dies it takes
all of the modules with it.  To fix this, lovr<Module>Init will return
whether or not initialization successfully happened, which provides us
with enough info to know if we should place the luax_atexit destructor
2018-11-19 09:24:28 -08:00
bjorn 465e5c2010 Controller:getVelocity; Controller:getAngularVelocity; 2018-11-19 09:24:10 -08:00
bjorn e5dd0a2c17 Fix wasm build.........; 2018-11-16 07:36:44 -08:00
bjorn 6168ec243f Add platform/glfw.h;
Platforms that want to use glfw for most of their platform code can
include "glfw.h" for common functions, in a single-file-lib fashion.

All glfw code is in this file.
2018-11-16 07:24:20 -08:00
bjorn 217a2f6354 Fix problems not caught by MSVC; 2018-11-16 07:19:29 -08:00
bjorn ca0034e0aa rm lib/glfw; 2018-11-16 04:44:36 -08:00
bjorn ba253a0716 oculus_mobile: lovrPlatform instead of glfw;
please don't break!
2018-11-16 04:44:20 -08:00
bjorn c9793eae49 lovrPlatform: init/destroy; 2018-11-16 03:59:06 -08:00
bjorn b7deda3758 lovrPlatform: Keyboard/mouse;
Update fake.c
2018-11-16 03:18:08 -08:00
bjorn 5c3280ba2a boot.lua: Improve errors when loading modules fails;
Remove hardcoded list of modules as well.
2018-11-16 02:27:34 -08:00
bjorn ba60e99890 lovrPlatform: Window creation; 2018-11-16 02:26:56 -08:00
bjorn 6514492cb8 glfwGetTime -> lovrPlatformGetTime;
Same for glfwSetTime;
2018-11-16 00:28:45 -08:00
bjorn 4cd5505ac2 glfwPollEvents -> lovrPlatformPollEvents; 2018-11-16 00:24:43 -08:00
bjorn da92cce634 Fix wasm build; 2018-11-15 08:21:26 -08:00
bjorn 005d4b93f2 Move math helpers into lib;
They aren't really part of the math module since they are shared
across several modules, more "util"-y.
2018-11-15 08:03:51 -08:00
bjorn 2238f51338 Use lovrLog functions in oculus_mobile.c;
Question: Are we okay to simplify log levels to DEBUG/WARN?  If not,
maybe we add a LOVR_LOG_LEVEL thing...
2018-11-15 07:51:21 -08:00
bjorn 81451eb99d rm trailing whitespace; 2018-11-15 07:51:21 -08:00
bjorn ab232571d0 Make sure error messages get printed; 2018-11-15 07:51:21 -08:00
bjorn 0b78e238b3 luax_traceback;
Simplifies traceback code by adding a polyfill for Lua 5.2's
luaL_traceback function that can be used by the panic helper and
luax_getstack.
2018-11-15 07:51:21 -08:00
bjorn c6126bed59 Move print_override to luax;
It makes more sense for it to live there since it's a Lua override.
I misunderstood something when communicating about this initially.
2018-11-15 07:51:21 -08:00
bjorn 784d61ef4a Modify module loading;
Dynamically loading things was cool but is causing more pain than
pleasure because it just barely doesn't work everywhere.  Instead,
find a better way to load modules.  Use a data driven luaL_Reg array
to define the module mapping and luaL_register to smoosh it into
package.preload at boot time.  Benefits:

- LOVR_ENABLE_<x> defines are respected and only require a single #if
- Module list is data driven and defined in one place
- It's faster (luax_preloadmodule did a global lookup every invocation)
- It works everywhere

Oh also threads were totally broken and this (mostly) fixes them.
2018-11-15 07:51:21 -08:00
bjorn 0cf52a2ce8 Attempt to use macros for android logging;
Does this work?  It seems like it should.  If it doesn't, let's use
functions consistently for logging on all platforms.
2018-11-15 07:51:21 -08:00
bjorn 7ff12740b8 rm trailing whitespace; 2018-11-15 07:51:21 -08:00
mcc 64b187ef3f Manual merge args-and-physfs PR branch with master 2018-11-13 22:09:47 -05:00
mcc 91daeae634 Style/functional fixes to args for PR. --inside is now --root 2018-11-13 22:07:19 -05:00
mcc 96eed2786c Amend oculus_mobile error handling so headset.c renderHelper drives
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).
2018-11-13 16:50:31 -08:00
mcc 684fd77316 Various changes around error reporting to support Oculus Mobile
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")
2018-11-13 16:50:31 -08:00
mcc 2213b3bcfd Allow the mountpoint to be set "inside" a zip file, using an --inside parameter.
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.
2018-11-13 15:20:04 -05:00
mcc 26af794e3c Adjust the lovr command line construction to follow the lua/love standards. This is a BC-breaking change.
Source for lua standard: https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter
2018-11-13 16:28:56 -05:00
bjorn a1237029de lovr.graphics.translate: Arguments default to 0; 2018-11-12 19:28:41 -08:00
bjorn 7e1527ddca (Ab)use calloc for OpenVR controller models;
Avoids a potential invalid call to free on destroy.
2018-11-12 19:00:17 -08:00
bjorn 4188fd53ec Handle tabs in fonts; 2018-11-11 18:28:51 -08:00
bjorn 185bb8438e Set error handler context to correct Lua state; 2018-11-11 17:33:16 -08:00
bjorn 112d775635 Font:hasGlyphs; 2018-11-11 17:29:41 -08:00
bjorn 20ddad4a9e Improve error message when glyph is not found; 2018-11-11 17:17:42 -08:00
bjorn 8b2f0eb0ba Add newline to glfw.h; 2018-11-08 14:13:39 -08:00
bjorn 76c2dc757a Curve:getTangent; 2018-11-08 12:56:45 -08:00
bjorn 2703192f1d Make a constructor; 2018-11-08 12:56:45 -08:00
bjorn 2acf49fb34 Curve; 2018-11-08 12:56:45 -08:00
bjorn a06734ae97 Use alpha to coverage and alpha test for text; 2018-11-08 11:58:43 -08:00
bjorn bfeb3d2d51 lovr.graphics.discard; 2018-11-08 11:58:31 -08:00
mcc b01a349275 Merge Windows build fixes for SDS library, from https://github.com/LynnKirby/sds fork commit 1ea0479693a8fd85351b75a6d41cef40a8e3e67c 2018-11-07 17:03:31 -05:00
mcc a46b4afbb8 Split out the "oculus mobile" headset type into GEAR and GO. 2018-11-07 14:34:51 -05:00
mcc 2675b51013 Make oculus mobile build self-contained
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.
2018-11-07 10:24:44 -05:00
mcc b146ad422f Add SDS string library from commit 8dc8d6fb373bdc08eb82a72904841998d30b7cf2 2018-11-06 18:39:12 -05:00
mcc d8de87d789 Fix headset and controller poses 2018-11-06 15:56:27 -05:00
mcc bf7fd349e2 Fix math bug in glfwSetTime 2018-11-06 11:28:45 -05:00