Sharing a screencopy texture between a gadget and a widget

Sharing a screencopy texture between a gadget and a widget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Sharing a screencopy texture between a gadget and a widget

Post 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?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Sharing a screencopy texture between a gadget and a widg

Post 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.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Sharing a screencopy texture between a gadget and a widg

Post by Beherith »

A texture is just a handle to a gl int as far as I know, so that might work. Ill try it :)
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Sharing a screencopy texture between a gadget and a widg

Post by gajop »

If that worked it would be a bug. It would mean you could change any gadget's texture from a widget.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Sharing a screencopy texture between a gadget and a widg

Post by Beherith »

Yay, it can be done!
!56 = lua generated texture 56 (= return value of gl.CreateTexture)
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Sharing a screencopy texture between a gadget and a widg

Post 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.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Sharing a screencopy texture between a gadget and a widg

Post 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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Sharing a screencopy texture between a gadget and a widg

Post 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
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Sharing a screencopy texture between a gadget and a widg

Post by Beherith »

If I did it between widgets only, would it work there?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Sharing a screencopy texture between a gadget and a widg

Post by jK »

why shouldn't it?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Sharing a screencopy texture between a gadget and a widg

Post 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.
Post Reply

Return to “Lua Scripts”