Page 1 of 1
Sharing a screencopy texture between a gadget and a widget
Posted: 28 Nov 2013, 12:19
by Beherith
I have a gadget and a widget that both use a texture that is made by copying the screen. I wish to avoid doing the copy operation twice. Can this be done?
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 28 Nov 2013, 13:09
by Silentwings
You could try _G (
http://springrts.com/wiki/Lua_sync_to_unsync) but I'm not sure what the limitations on how much data can be sent around at once like that are.
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 28 Nov 2013, 19:26
by Beherith
A texture is just a handle to a gl int as far as I know, so that might work. Ill try it :)
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 28 Nov 2013, 19:38
by gajop
If that worked it would be a bug. It would mean you could change any gadget's texture from a widget.
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 28 Nov 2013, 19:48
by Beherith
Yay, it can be done!
!56 = lua generated texture 56 (= return value of gl.CreateTexture)
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 04:47
by Silentwings
If that worked it would be a bug. It would mean you could change any gadget's texture from a widget.
_G (amongst other ways) lets you to do stuff in synced and have it visible to unsynced.
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 06:26
by gajop
Silentwings wrote:
_G (amongst other ways) lets you to do stuff in synced and have it visible to unsynced.
Yes and the point is you don't even need _G to 'transfer' textures (as they're just gl ints). Also this isn't just synced<->unsynced gadget communication (both between 'trusted' code), rather it's gadget<-> widget communication.
OTOH, if you think users have the full right to decide what gets rendered on their screen, it's fine.
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 06:31
by jK
Beherith wrote:Yay, it can be done!
!56 = lua generated texture 56 (= return value of gl.CreateTexture)
No.
Yes gl.CreateTexture returns a native type (string iirc)
but this is only valid in the specific lua instance.
if you want to share a screencopy try:
1. setup render enviroment & bind texture in LuaRules
2. call Script.LuaUI.Foobar()
3. render in LuaUI
4. then finish everything in LuaRules
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 09:24
by Beherith
If I did it between widgets only, would it work there?
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 09:27
by jK
why shouldn't it?
Re: Sharing a screencopy texture between a gadget and a widg
Posted: 29 Nov 2013, 13:46
by Silentwings
gajop wrote:Yes and the point is you don't even need _G to 'transfer' textures (as they're just gl ints).
I don't think so (and maybe this is also what jK is saying) - I don't know if its enough just to transfer the gl int because maybe that int is only valid within the lua state in which it was created.