From 10517a1d90cac83dd55abb978ed60cf964a440aa Mon Sep 17 00:00:00 2001 From: s-ol Date: Fri, 10 Apr 2026 15:23:54 +0200 Subject: check errors in Canvas:send/recv, disable with fail_silently --- README.md | 4 ++-- texture-share-vk.lua | 12 ++++++++---- 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) -- cgit v1.2.3