Commit Graph

2432 Commits

Author SHA1 Message Date
mcc 6f45b90044 Fix CMakeLists.txt after animator removed 2019-07-11 13:30:26 -07:00
bjorn 8e2775ef6d Math: cleanup; 2019-07-11 11:35:50 -07:00
bjorn 6b87576e6d Channel: cleanup; 2019-07-11 11:29:18 -07:00
bjorn 8c76e6f19b RandomGenerator: cleanup; 2019-07-11 11:24:34 -07:00
bjorn 1f8a7e073f Curve: cleanup; 2019-07-11 11:22:03 -07:00
bjorn f81a65430b Add support for cubic spline keyframe interpolation; 2019-07-11 11:05:53 -07:00
bjorn 3c07ad6b0b Replace Animator with Model:animate; 2019-07-10 22:08:19 -07:00
bjorn 4372eb293e rm comma operator;
everyone is making fun of me haha
2019-07-10 18:46:51 -07:00
mcc f5633f4248 Fix lovr.filesystem.append()
Previously, this program function lovr.update(dt) lovr.filesystem.append("/test123", lovr.timer.getTime()) end would fail in lovr because lovrFileWrite required the file to be in write mode (not append)
2019-07-10 16:29:09 -07:00
bjorn 82b865d851 Tuprules: Always use C99;
Now that we mostly use the clang/gcc atomics, just use c99 all the
time instead of conditionally changing the C standard.
2019-07-10 16:25:47 -07:00
mcc a6936b5649 Fix -DLOVR_ENABLE_THREAD=OFF compile
l_event.c was processing a thread-related event and in the process using a thread struct, even when LOVR_ENABLE_THREAD is undefined and threads do not exist. I caused the thread event type to simply not exist when the thread module is not being built.

Since the event is now only sometimes present, I put it at the end of the enum as slight protection against binary mismatches with dynamically loaded modules.
2019-07-10 16:23:20 -07:00
mcc 070892ee12 Fix crash with lovr.event.quit("restart") on Oculus Mobile
Because of how and when draws occur in our Oculus Mobile path, during a restart it would attempt to draw a frame after lovrGraphicsDestroy() is called, leading to a crash in lovrGraphicsSetCamera(). This blocks draws until the restart is finished and renderTo() has been called (conveniently detectable using the existing state.renderCallback).
2019-07-10 16:10:02 -07:00
mcc 8bfc8683db Patch maf.h so it can be included in C++
A C-only feature is used in one spot currently, which would be fine if maf.h were maf.c, but it's designed to be #included...
2019-07-10 14:58:55 -07:00
mcc 38886f0dc4 Patch sds.h so that it can be #included from C++
Empty arrays aren't allowed in C++, so a single dummy element has to be added. sds works by scary cast magic so this dummy element is never actually allocated. A #define is used in this patch so in C this compiles exactly the same as before.
2019-07-10 14:58:55 -07:00
mcc 99f8122f23 ref.h compiles in C++
Check for GCC version >=4.7 [covers GCC or, theoretically, Intel C Compiler] or __has_builtin(__atomic_add_fetch) [covers Clang]. If either of these are found, prefer the GCC atomic builtins instead of the C11 builtins.

Also: Gates Microsoft atomics on _MSC_VER, not _WIN32. This may help improve compatibility with mingw but has not been tested.
2019-07-10 14:58:25 -07:00
bjorn f208a5e067 Fix array initialization;
Because the new arr.h contains an array on the stack, we can't
initialize it and then copy it, or the pointer to the stack array
will be pointing to the wrong thing, causing incorrect behavior.
2019-07-09 09:06:11 -07:00
bjorn af29e29e4d Fix lovr.graphics.setProjection;
Needed to be using new frameData stuff.
2019-07-08 14:35:54 -07:00
bjorn f2feda9420 oculus: Remove offset;
Since we are calling SetTrackingOriginType with floor level, we don't
need to apply the seated-level t.headset.offset adjustment.
2019-07-05 01:05:02 -07:00
bjorn 348798b86c Make shader in nogame screen more correct; 2019-07-02 20:12:24 -07:00
mcc dc98846169 Fix error screen on Android
As discussed in slack, lovr.errhand appears to predate lovr.graphics.hasWindow() and does not use it. This resulted in a crash on Oculus Go
2019-07-02 18:45:08 -07:00
mcc 53270fbd76 mat4_transform_project in maf.h
mat4_transform ignores the final row of the matrix, which normally contains scale data. This is fine for modelview matrices, which is all lovr currently uses mat4_transform for. However it fails if you ever use mat4_transform on a projection matrix.

mat4_transform_project takes the final row into account, so you can use it with projection matrices. This was useful in my fork and might be useful to have around in lovr someday later.
2019-07-02 13:37:33 -07:00
mcc 1b085a00ea As discussed in slack, Oculus should be letting lovrCanvasCreate decide whether to double 2019-07-02 13:28:36 -07:00
bjorn 57f97056da Use I4ui instead of I1ui for lovrDrawID constant value;
glVertexAttribI1ui isn't supported on GLES for some reason.
2019-07-02 12:51:36 -07:00
bjorn 2d6aa18069 Be a little more correct about when draw id is written; 2019-07-02 00:14:01 -07:00
bjorn 775cf5cda1 Don't accidentally draw meshes too many times;
Oops!
2019-07-02 00:09:43 -07:00
bjorn 44da36b610 Write draw ids at the right time (fix flicker); 2019-07-01 02:47:59 -07:00
bjorn 2fb393306c rm skybox args;
They used to always be necessary, now they are almost never necessary.
2019-06-29 21:01:03 -07:00
bjorn e3e930d6cc Set index buffer at the right time;
Just a small ordering issue with previous commit.
2019-06-29 20:39:01 -07:00
bjorn 6256acfc6d Ahhh fix everything;
- If you have an instanced batch, it will use the instanced mesh.  That
  has a drawID attribute that uses the identity buffer, which has a vertex
  divisor.  BUT if you only have one instance, then we won't emit an
  instanced draw, and the use of a divisor'd attribute w/ a non-instanced
  draw is causing mega problems on macOS.
- This also fixes observed macOS bugs like:
  - Needing to have a small UBO
  - Flickering at startup
  - Flicker when writing to the last byte of a UBO
  - etc.
- Also make the generic attribute value for lovrDrawID more correct (scalar instead of vector).
2019-06-29 20:24:36 -07:00
bjorn afe4d8c0e3 Fix GL error with buffer unmapping;
This doesn't seem to fix any of the macOS rendering bugs though...
2019-06-29 20:08:31 -07:00
bjorn d3f08fd1f0 rm logo.png; 2019-06-29 18:28:20 -07:00
bjorn b2df3e9816 Update nogame screen;
- Slightly dim background color (may change).
- Use a shader for the logo (it's centered now, not quite 100% like the image).
- Adjust text optical weight (I hate it).
2019-06-29 18:27:55 -07:00
bjorn e82ba030a6 lovr.headset.getDisplayTime;
Returns the predicted display time, which is the estimated time at which
the photons of the next frame will hit the eyeballs of a person in the HMD.

This should be used instead of lovr.timer.getTime when used for rendering
something that is time-dependent.  Updating simulations, logic, or access
to high frequency times should still use lovr.timer.getTime.
2019-06-29 17:36:36 -07:00
bjorn 8faff22f38 Regenerate math.lua.h; 2019-06-28 22:07:31 -07:00
bjorn d87fc56b63 lovr.headset.getDisplayMask; 2019-06-28 00:13:45 -07:00
bjorn 79a19ef267 Fix M_PI redefinition;
We just set it in util now.
2019-06-28 00:13:45 -07:00
bjorn 4222be88b5 Use UBO for Camera matrices;
Ugh I don't like the "Camera" concept anymore, but I can't figure
out how to easily get rid of it.  Maybe wait till displays are a thing.
2019-06-27 22:17:50 -07:00
bjorn fa6c4a6b39 Organization; 2019-06-27 21:04:15 -07:00
bjorn 370124c88d Batching cleanup;
- Rename drawMode to topology in some places.
- Batch uses DrawCommand internally to simplify stuff.
- Do less work while flushing.
- Store global head/tail cursors instead of unused per-batch cursors.
2019-06-27 20:58:42 -07:00
bjorn 779949964f More small batching changes;
- Reduce number of batches to 4.  Yeah it's arbitrary, will monitor.
- Just use memcmp for BatchParams.  Since we're using designated initializers,
  we aren't running into issues with memcmp+struct padding bits, and in the
  event it does lead to false positives on some platforms, at worst we'll just
  experience a harmless reduction in batching efficiency.
2019-06-27 19:05:54 -07:00
bjorn 6da17b0a91 Optimize gamma correction;
Currently, we gamma correct colors on every clear and every draw.
It's taking a lot of time.  Instead, we'll gamma correct colors
when they're changed using lovr.graphics.setColor/setBackgroundColor.
2019-06-27 15:41:57 -07:00
bjorn 7e067da8e7 Add defaultCanvas;
Having a normal Canvas object that represents the backbuffer reduces
some indirection where we have to last-minute check if a Canvas is
set.  It also means that all of the draw-related info that was _sometimes_
on the Canvas is now _always_ on the Canvas, which reduces the amount
of redundant information we need to provide for a draw call.

There may be some issues related to changing the width/height/stereo
of the default Canvas.
2019-06-27 15:36:51 -07:00
bjorn 111872904a Update LuaJIT; 2019-06-27 15:01:52 -07:00
bjorn 26e474bcfc Simplify Mesh handling;
Removes some indirection from flush (I guess moves it into batch,
not sure what's better).
2019-06-27 14:14:31 -07:00
bjorn 551dea8c86 Adjust includes; 2019-06-27 13:44:09 -07:00
bjorn b8e63adcbf graphics: Cleanup;
Make batching structs and defines private.
2019-06-27 13:38:38 -07:00
bjorn fe21de403b lovrGraphicsDrawMesh; 2019-06-27 13:35:43 -07:00
bjorn b3080ae5d9 rm macos instancing hack;
I haven't been able to see adverse affects from it anymore.  Can
always put it back if it resurfaces.
2019-06-27 13:27:43 -07:00
bjorn 39b0d2d754 graphics: Minor refactoring; 2019-06-27 13:26:39 -07:00
bjorn 297208c205 Minor cleanup to stream buffer code; 2019-06-27 13:01:04 -07:00