Sharing a screencopy texture between a gadget and a widget
Moderator: Moderators
Sharing a screencopy texture between a gadget and a widget
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?
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Sharing a screencopy texture between a gadget and a widg
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
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
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
Yay, it can be done!
!56 = lua generated texture 56 (= return value of gl.CreateTexture)
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Sharing a screencopy texture between a gadget and a widg
_G (amongst other ways) lets you to do stuff in synced and have it visible to unsynced.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
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.Silentwings wrote: _G (amongst other ways) lets you to do stuff in synced and have it visible to unsynced.
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
No.Beherith wrote:Yay, it can be done!!56 = lua generated texture 56 (= return value of gl.CreateTexture)
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
If I did it between widgets only, would it work there?
Re: Sharing a screencopy texture between a gadget and a widg
why shouldn't it?
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Sharing a screencopy texture between a gadget and a widg
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.gajop wrote:Yes and the point is you don't even need _G to 'transfer' textures (as they're just gl ints).