aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2026-04-10 13:23:54 +0000
committers-ol <s+removethis@s-ol.nu>2026-04-10 13:23:54 +0000
commit10517a1d90cac83dd55abb978ed60cf964a440aa (patch)
tree85e94391f18a0998363c5e3edd253b2aa9d55b6b
parentrelease 0.1.1 (diff)
downloadlua-texture-share-vk-10517a1d90cac83dd55abb978ed60cf964a440aa.tar.gz
lua-texture-share-vk-10517a1d90cac83dd55abb978ed60cf964a440aa.zip
check errors in Canvas:send/recv, disable with fail_silently
-rw-r--r--README.md4
-rw-r--r--texture-share-vk.lua12
2 files changed, 10 insertions, 6 deletions
diff --git a/README.md b/README.md
index 9ab89ea..48139d3 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,6 @@ This wraps the OpenGL C API of [texture-share-vk](https://github.com/DigitOtter/
- `Client:loadSharedCanvas(name)`: loads a `SharedCanvas` object from another publisher.
- `Canvas.name`: the name passed in the SharedCanvas constructor
- `Canvas.canvas`: the love2d `Canvas` object
-- `Canvas:send()`: Sends the current contents of the Canvas to subscribers, call this after drawing to the Canvas.
-- `Canvas:load()`: Loads updated contents from the publisher, call this before drawing the Canvas.
+- `Canvas:send([fail_silently])`: Sends the current contents of the Canvas to subscribers, call this after drawing to the Canvas.
+- `Canvas:load([fail_silently])`: Loads updated contents from the publisher, call this before drawing the Canvas.
- `Canvas:any_other_method()`: delegated to the love2d `Canvas` object
diff --git a/texture-share-vk.lua b/texture-share-vk.lua
index f8f9c4c..3ec1250 100644
--- a/texture-share-vk.lua
+++ b/texture-share-vk.lua
@@ -209,8 +209,8 @@ function Client:__gc()
tvs.gl_client_destroy(self)
end
-function Canvas:send()
- return tvs.gl_client_send_image(
+function Canvas:send(fail_silently)
+ local status = tvs.gl_client_send_image(
self.client.client,
self.name,
self.texture_id,
@@ -219,10 +219,12 @@ function Canvas:send()
0,
nil
)
+ assert(status >= 0, "error sending image")
+ assert(fail_silently or (status == 1), "send: image not found")
end
-function Canvas:recv()
- return tvs.gl_client_recv_image(
+function Canvas:recv(fail_silently)
+ local status = tvs.gl_client_recv_image(
self.client.client,
self.name,
self.texture_id,
@@ -231,6 +233,8 @@ function Canvas:recv()
0,
nil
)
+ assert(status >= 0, "error receiving image")
+ assert(fail_silently or (status == 1), "recv: image not found")
end
function Canvas:__index(key)