Commit Graph

226 Commits

Author SHA1 Message Date
bjorn 7f22e18533 Error better when Buffer field is missing type; 2022-06-25 23:43:24 -07:00
bjorn f729320793 Fix creating Material from Texture; 2022-06-24 19:38:23 -07:00
bjorn 173c9a258e Sketch render pass automipmap; 2022-06-22 19:05:36 -07:00
bjorn cb4275bff7 Add DrawStyle; 2022-06-22 00:05:26 -07:00
bjorn ad0595ff35 lovr.graphics.getDefaultFont; 2022-06-20 18:58:12 -07:00
bjorn 362b389131 Pass:text;
Code is still messy, but it works okay.
2022-06-20 18:26:15 -07:00
bjorn a654cec40f lovr.graphics.newFont; 2022-06-18 17:43:12 -07:00
bjorn b89c61a8f4 HorizontalAlign and VerticalAlign enums; 2022-06-18 17:41:10 -07:00
bjorn 86b2c934e8 Materials, mostly; 2022-06-16 23:49:09 -07:00
bjorn 7de6bdf242 Shaders; Rework vertex formats; 2022-06-15 20:46:43 -07:00
bjorn fc616f92c2 Pass:mesh; Pass:setMeshMode; 2022-06-09 23:05:32 -07:00
bjorn b2e681ddfd Allow hexcode for render pass clear; 2022-06-09 17:37:06 -07:00
bjorn c2dab3cf2c Update lovr.draw signature;
- If you return a truthy value from lovr.draw, the pass won't be
  submitted.  A falsy value will submit the input pass.
- For convenience, lovr.graphics.submit returns true.
2022-06-08 23:59:48 -07:00
bjorn e36cc6482d rename pass/buffer to getPass/getBuffer; 2022-06-05 18:56:03 -07:00
bjorn 0104fe1910 Fancy compare mode aliases; 2022-05-31 21:33:06 -07:00
bjorn 99e45c22ad Add some descriptor set limits; 2022-05-31 20:16:16 -07:00
bjorn ff77a30f01 Default shaders; 2022-05-27 20:47:20 -07:00
bjorn 885e335f8c Image dimension accessors take mip level; 2022-05-25 23:51:51 -07:00
bjorn 070e4f304d lovr.graphics.get/setBackground; 2022-05-11 15:38:05 -07:00
bjorn 970a84a514 Surface, swapchain, window texture, vsync; 2022-05-11 15:28:04 -07:00
bjorn f7b4ec725f Render passes; 2022-05-11 12:51:13 -07:00
bjorn 24f09ea608 lovr.graphics.submit works; 2022-05-11 12:50:49 -07:00
bjorn bfa0d94f2d Pass pipeline API; 2022-05-11 12:50:26 -07:00
bjorn d9e5ba8b9f Slightly broken compileShader/newShader; 2022-05-09 11:47:06 -07:00
bjorn 5d078461a2 Rename copy texture usage to transfer; 2022-05-06 17:26:59 -07:00
bjorn 1fde5a36d0 Transform stack; 2022-05-06 17:26:38 -07:00
bjorn 7ac9f357d8 Sampler API; 2022-05-01 15:48:41 -07:00
bjorn 22e15513f9 Sampler; 2022-05-01 15:47:17 -07:00
bjorn 211e3ef0f8 Compile fixes; 2022-05-01 15:18:56 -07:00
bjorn 77a32333e0 lovr.graphics.pass; 2022-04-30 18:56:38 -07:00
bjorn ebe77e5924 Sketch out Texture uploads; 2022-04-30 18:49:46 -07:00
bjorn 0772d8b4de newTexture; 2022-04-30 03:06:14 -07:00
bjorn e80d254dc6 Texture API;
Except newTexture because it's hard or something
2022-04-29 20:56:23 -07:00
bjorn e53ddfa03b isFormatSupported; 2022-04-29 17:16:16 -07:00
bjorn 48e2509a3c lovr.graphics.wait; 2022-04-28 22:37:03 -07:00
bjorn 7aee0a4656 Add Pass; Buffer transfers; lovr.graphics.submit; Bugfixes; 2022-04-28 22:30:31 -07:00
bjorn 874c35120b mv getBuffer buffer; 2022-04-28 20:57:36 -07:00
bjorn 6ee2b901f7 Fix to buffer constructor; 2022-04-28 20:26:47 -07:00
bjorn a97193caac Buffer stride can not be smaller than the size of a single item; 2022-04-28 15:39:45 -07:00
bjorn e8c809a870 Temporary buffers; 2022-04-27 00:28:39 -07:00
bjorn a3438274b5 Add non-scratchpad Buffers;
This includes the memory allocator and the morgue.

You can't actually write any data to the buffer yet, since we don't have
commands or temp buffers.  Temp buffers (scratchpads) are coming soon.
2022-04-26 15:32:54 -07:00
bjorn 50ebed697e Update some features and limits;
- rm dynamicIndexing and nonUniformIndexing, for now (arrays aren't well
  supported)
- rename compressed texture features
- move clip/cull distance to limit instead of feature (limit can be 0)
2022-04-26 15:31:51 -07:00
bjorn 3ae0ff568f Rework device info; 2022-04-22 13:28:59 -07:00
bjorn be1cedc922 Always enable fullIndexBufferRange feature; 2022-04-22 01:07:07 -07:00
bjorn f37c1824da lovr.graphics.getDevice/getFeatures/getLimits; 2022-04-21 17:39:59 -07:00
bjorn 40e9a4ab73 core/gpu; 2022-04-21 17:39:59 -07:00
bjorn 37221afbc6 rm graphics module; 2022-04-21 17:39:58 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn a4faad39f8 Font:getFilter; Font:setFilter; 2022-03-15 16:02:35 -07:00
bjorn 17c05b1760 Merge branch 'master' into dev 2022-03-14 14:10:25 -07:00
bjorn fdfcb5539f Merge branch 'master' into dev 2022-03-14 13:19:59 -07:00
bjorn c9fe026a66 Fix undefined behavior in arr_free;
Currently there is a single allocator function used in arr_t.  Its
behavior depends on the values for the pointer and size arguments:

- If pointer is NULL, it should allocate new memory.
- If pointer is non-NULL and size is positive, it should resize memory.
- If size is zero, it should free memory.

All instances of arr_t use realloc for this right now.  The problem
is that realloc's behavior is undefined when the size argument is zero.
On Windows and Linux, realloc will free the pointer, but on macOS this
isn't the case.  This means that arr_t leaks memory on macOS.

It's best to not rely on undefined behavior like this, so let's instead
use a helper function that behaves the way we want.
2022-03-14 12:27:58 -07:00
murat g ee3ba6ef3e Font filtering now respects the default setting. 2022-03-03 22:41:47 -08:00
bjorn b22dbd8f0c Add luax_checku32 and luax_optu32;
These functions read an unsigned 32 bit integer from the Lua stack
and error if the value is negative or too big.  Currently converting
Lua numbers to integers will silently wrap or invoke undefined behavior
when they are outside of the acceptable range.

For projects that don't want the overhead of type/bounds checks, the
supercharge build option (LOVR_UNCHECKED) can now be used to skip all
type/bounds checks.
2022-02-21 14:19:24 -08:00
bjorn 7ed47e946b Fix problem when requiring audio/graphics/headset in threads;
These modules access the conf table, which isn't available on threads.
2022-01-16 12:13:46 -08:00
bjorn 8462beef00 Fix/improve alpha cutoff;
The current flag did not work because float shader flags are not
supported.  It was also not very useful because it was per-shader
and did not use the alpha cutoff property of glTF materials.

Instead, let's turn the shader flag into an enable/disable boolean,
and add a scalar material property named "alphacutoff" that gets
read by the glTF importer.

When the alphaCutoff flag is enabled, the material property will be
compared against the pixel's alpha value to decide whether it should
get discarded.
2021-12-28 21:10:52 +02:00
bjorn 2b1b777e84 Fix crash when passing nothing to newTexture; 2021-03-26 20:02:38 -06:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn deb756392b Fix 'attempt to flush unmapped buffer' when creating empty Mesh; 2021-03-07 21:19:24 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn 39a4d2c1d5 rm lovr.graphics.triangle; 2021-02-24 17:45:31 -07:00
bjorn a0b2200bef Fix lovr.graphics.getBlendMode when blending is off; 2021-02-19 14:05:18 -07:00
bjorn 0365f51f9d Fix crash when drawing zero lines; 2021-02-19 08:38:45 -07:00
bjorn 0919da4091 Improve MSDF font shader; Add spread/padding settings to Font; 2021-02-10 07:08:29 -07:00
bjorn 8164e0b6e8 TextureData is now named Image!;
The existing Image construct was renamed StorageImage.
2021-02-08 20:17:47 -07:00
bjorn 8c714c45b0 Clean up some includes; 2021-02-08 11:16:00 -07:00
bjorn 6d92d54079 Try having arr_t in util; 2021-02-08 18:25:05 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjorn 1e7749a58a Fix MSVC warnings;
It's that time of year.
2020-11-12 18:08:05 -07:00
Nevyn Bengtsson 326d275424 don't free window icon before it's used
It seems to me like that lovrRelease will delete textureData->blob immediately,
which means the windowing system later can't use it because it's already freed.
There's already a free on line 378 which looks more correct.

Also, icon appears flipped if 'flipped' is set to true here on Linux. Is GLFW
inconsistent between linux and windows, or should it indeed be false?
2020-11-06 21:00:38 +01:00
bjorn 51f470cf85 Easier enums; 2020-09-27 17:13:00 -07:00
bjorn f1447fd69a lovr.graphics.get/setViewPose; lovr.graphics.get/setProjection; 2020-09-24 19:03:37 -07:00
bjorn c7ca7eaa38 Add compute dispatch limit; 2020-09-18 15:19:34 -07:00
bjorn ec257b179f Support Lua 5.2, 5.3, 5.4; 2020-08-19 13:12:57 -06:00
bjorn d937be35b5 Fix lovr.graphics.line(nil); 2020-08-17 14:43:46 -06:00
bjorn 82159a9885 rm persistent mapping; sync Mesh and ShaderBlock; 2020-08-17 03:29:30 -06:00
bjorn e3aa4c7d5d t.graphics.debug flag; 2020-07-28 16:12:15 -06:00
bjorn 6bce095660 Fix newComputeShader(nil); 2020-06-07 15:47:53 -06:00
bjorn 1185fcf6e1 Autodetect integer attribute types;
Fixes inability to use integer attributes with Mesh.
2020-05-21 00:31:49 -06:00
bjorn 1e78ac8669 Add r16, rg16, rgba16 texture formats; 2020-05-10 01:59:58 -06:00
bjorn a01cc5a376 Fix lovr.graphics.getDefaultFilter; 2020-03-05 19:27:08 -08:00
bjorn c02839f5c2 Allow anisotropy to be used with any TextureFilter;
Instead of anisotropic being its own filter, it is now removed and
anisotropy settings can be used with any of the other filter modes.
2020-03-05 09:46:49 -08:00
bjorn 18dcb07b98 Convert stuff over to use new enum system; 2020-02-16 18:31:02 -08:00
bjorn 67ba5f3a82 Add more graphics stats; 2020-01-31 03:43:52 -08:00
bjorn 78f272247b newCanvas creates array textures when multiview; 2020-01-30 17:48:01 -08:00
bjorn 56dc8d0b9e Handle stereo shaders better;
- Creating a shader from a DefaultShader will respect the stereo flags.
- Auto shaders will properly be stereo/nonstereo based on the target Canvas.
2020-01-27 16:33:15 -08:00
bjorn 4379d25e1c Organization; 2020-01-27 14:02:54 -08:00
Cassie Jones 3e09120173 Compile shaders using source lengths
The previous implementation relied on glShaderSource inferring source
lengths when the lengths weren't specified. This relies on the sources
being properly null-terminated, however, which isn't the case due to
file loading changes which now use pointer + length. This could cause
intermittent crashes.

Changing this on the shader side meant adding some extra arguments for
passing around shader source lengths. For most of the other cases, where
we're using string literals as the sources, we can just specify -1 as
the length, since OpenGL will calculate the string length for you any
time the length is negative.
2020-01-27 16:13:21 -05:00
Nevyn Bengtsson 95edb43654 TextureData: holds Blob instead of being Blob, just like SoundData
also replaces TextureData:getPointer with TextureData;getBlob
2020-01-19 22:59:44 +01:00
bjorn a103637419 Fix ModelData refcounting; 2019-12-20 04:52:55 -08:00
bjorn e316e6156b lovr.graphics.get/setColorMask; 2019-12-10 13:44:51 -08:00
bjorn 403ed8d3b0 Windows; 2019-12-10 12:19:50 -08:00
bjorn 1902787b1b Modify GPU timer API;
- lovr.graphics.tock returns the latest value of the timer, or 0.
- Timers are not in the stats table anymore.

This is to prepare for an upcoming internal change that affects timers.
2019-09-18 18:21:38 -07:00
bjorn 00412e2e79 Add a conf.lua flag for making the window resizable; 2019-08-28 00:59:03 -07:00
bjorn 31fed6a940 Fix stereo flag for custom shaders; 2019-08-27 14:59:17 -07:00
bjorn 305596adf8 Fix windows build;
LOVR_EXPORT needs to be on the declaration, unfortunately.
2019-08-26 15:53:10 -07:00
bjorn 9b0e43b249 Fix t.window = nil; 2019-08-21 22:26:31 -07:00
bjorn 8d4760167f luax is now api; 2019-08-21 15:27:26 -07:00
bjorn 26e7233fde Fix some API issues with lightuserdata; 2019-08-19 14:35:06 -07:00
bjorn c703092f87 Add missing timers GraphicsFeature; 2019-08-13 22:11:59 -07:00
bjorn 93f076acc9 Fix default uniform values;
Not supported in GLES.
2019-08-09 17:36:14 -07:00
bjorn 289d365866 Better error messages when loading cubemaps; 2019-08-07 15:14:59 -07:00
bjorn 96c47d590c rm lovrEnvironmentTexture from Material; 2019-08-05 15:20:17 -07:00
bjorn 06fb8b2503 Simplify fill;
lovr.graphics.fill renders a fullscreen quad, it's convenient because
you don't need to set up a mesh and toggle all the pipeline states.

However, if you are dealing with copying/rendering between stereo
textures, you have to write your own shader for that.  For now.
2019-08-03 16:03:13 -07:00
bjorn 7690db28af Windows: Fix all the int warnings; 2019-07-31 17:51:49 -07:00
bjorn ca8e280dcd Fix texture refcounting in lovr.graphics.newTexture;
Also a memory leak with window icons (does anyone use that?)
2019-07-31 14:43:35 -07:00
bjorn 9156fa2cbf Vector rework; 2019-07-16 20:30:51 -07:00
bjorn 4b4020d3a7 Model:pose; Model:getNodePose; 2019-07-11 20:09:46 -07:00
bjorn 3c07ad6b0b Replace Animator with Model:animate; 2019-07-10 22:08:19 -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 551dea8c86 Adjust includes; 2019-06-27 13:44:09 -07:00
bjorn 928ccee5f1 Multiview; 2019-06-25 01:21:59 -07:00
bjorn 879c789a08 Polyfill M_PI;
It technically isn't part of C, which is causing problems on some systems.
2019-06-20 21:43:40 -07:00
bjorn 4611b1c9a3 Add no-op standard shader; 2019-06-20 14:21:35 -07:00
bjorn eb1e257209 Add new array implementation; Upgrade filesystem;
Filesystem:

- Uses streaming file IO.
- Uses less memory when requiring files.
- Simplifies its require path implementation.
2019-06-16 13:30:30 -07:00
bjorn 79083c7df1 Fix warnings on newer versions of gcc; 2019-06-11 19:57:20 -07:00
bjorn 98f4365474 Add astc and dxt GraphicsFeatures; 2019-06-09 23:59:57 -07:00
bjorn b0a7d5c122 ASTC textures;
I like typing numbers.
2019-06-09 09:11:29 -07:00
bjorn 06c6b172de vec3 has 4 elements; 2019-06-03 07:20:03 -07:00
bjorn 22fe333150 Update refcounting (again);
- Ref struct only stores refcount now and is more general.
- Proxy stores a hash of its type name instead of an enum.
- Variants store additional information instead of using a vtable.
- Remove the concept of superclasses from the API.
- Clean up some miscellaneous includes.
2019-06-02 01:02:26 -07:00
bjorn d2bff7d239 lovr.graphics.tick and tock;
Initial support for GPU timer queries.
2019-06-01 17:29:53 -07:00
bjorn c5210deae8 Fix ShaderFlag parsing; 2019-05-28 03:43:12 -07:00
bjorn 3bf08f0ca3 Add the ability to create default shaders;
lovr.graphics.newShader('font')
2019-05-22 18:00:02 -07:00
bjorn c464bde609 Add DefaultShaders enum; 2019-05-22 16:36:40 -07:00
bjorn 4a47afca38 Organize api folder; 2019-05-19 00:31:42 -07:00
Renamed from src/api/graphics.c (Browse further)