Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
is it possible to make my gideros app work with spout? — Gideros Forum

is it possible to make my gideros app work with spout?

keszeghkeszegh Member
edited April 2016 in General questions
i'd like to output what is on the stage (or even better on some sprite subhierarchy) of my app to spout (http://spout.zeal.co/ - a windows application) so other apps can use this as input (to put on it live effects and send it to a projector etc).
is this possible to write such a plugin e.g.?

Comments

  • any info from anybody? i've never touched visual studio windows development so i have not much idea. it seems basically sending an opengl texture (or directx, or what else, i don't geti t?) would be needed:
    see section 2.4 of:
    https://github.com/leadedge/Spout2/blob/master/SpoutSDK/Documentation/SpoutSDK.pdf

    is this theoretically possible with a gideros plugin?
  • keszeghkeszegh Member
    edited May 2016
    this question remains unanswered. any comments/ideas, gideros core programming experts? @ar2rsawseen, @john26, @hgy29?
    thanks in advance
  • ar2rsawseenar2rsawseen Maintainer
    Sorry, graphics and OpenGL is not my specialty, so I can't say for sure.

    but it would be great if you could explain, what exactly you want to achieve.

  • keszeghkeszegh Member
    this spout is a set of c++ classes, in the above linked pdf they explain how to do things. i need to do minimally these two things:
    -create a spout sender (sec2.3)
    -send the gideros stage as texture (sec2.4) on each enterframe of the gideros app
  • hgy29hgy29 Maintainer
    Maybe use RenderTarget as an entry point: RenderTarget is both a texture and a FBO. So your plugin would just need to get the texture id of the render target. But this is GL specific stuff which is not available on DX11 platform (WinRT), so it would mean exporting some api that would only work in some platforms.
  • hgy29hgy29 Maintainer
    On further thinking, you should be able to pass the RenderTarget object to your plugin, and the plugin would then be able to fetch the texture id from it. The only thing I am not sure about is if a plugin can actually query internal gideros structures...
  • keszeghkeszegh Member
    @hgy29, yes, that's why even if i could make a c++ plugin etc. i would not be able to do that for myself, as i don't know how one can pass a rendertarget object to the plugin.
    if you can tell me this, then perhaps i can start to work on it by reading how in general a win desktop plugin is made. of course it would still take 10x time as for you or anybody more capable than me, but of course i need this plugin and most other people do not, so that's understandable.

    btw for me a windows desktop export is quite enough, so it does not need to work on dx11.
  • keszeghkeszegh Member
    btw when i made an android plugin in the past, as there was an exported java project, it was somehow easier to do similar thing i guess.
    for windows desktop export there is no such intermediate step when i have a windows project that i can directly edit/hack. for universal apps there is but that's dx11 as you said so there might be additional problems.
  • if anybody has any idea on how to send screencapture/rendertarget from a gideros app to spout then let me know. i still have no clue how would i do that.

    perhaps the simplest would be to add this as a core feature, as the sdk of spout is pretty simple in itself. the most complicated part is only to make it a plugin i guess.

  • ok guys I came accross the spout thing but I would need some help for the wiki please ;)

    Somebody has any project which would demonstrate most of the plugin, setup and functions?

    Please, please, please :p

    Thank you
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • keszeghkeszegh Member
    edited December 2023
    something like this should do the job (of course you should render something on self.spoutRt to have an effect), you can try it by downloading spout and running spoutreceiver.
    require "spout"
     
      local w,h=_spoutWidth,_spoutHeight
     
      self.spoutSender=SpoutSender.new("GiderosApp",w,h)    
     
      self.spoutRt=RenderTarget.new(w,h)
     
    function onEnterFrame()		       	
    self.spoutSender:sendTexture(self.spoutRt)
    end

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2023
    Thank you nicely keszegh ;)

    Can we use Spout inside one Gideros app only (passing textures from maybe render target to render target, ...) or Spout main (and only?) goal is to allow applications to share video and still images with one another?

    In the latter case, that would mean building 2 Gideros apps that would send videos to one another (I am thinking a camera surveillance network)?

    I am a little bit confused here but that could be fun :)

    EDIT: regarding your code one app would send the video (the sender) then the other app would be the receiver?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2023
    Spout is designed for and by new media technologists, realtime video artists and visualists.


    I will see if I can make something out of it or not :p
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • keszeghkeszegh Member
    edited December 2023
    @MoKaLux , i use it to share live video with other apps.
    yes, i think spout plugin can be used to receive too, although i've never used that feature, but should be similarly simple to do (SpoutReceiver.new?). in which case indeed you can make two gideros apps where one can send the video to the other. also, with SpoutCam for example you can feed a virtual camera with live video. or using in addition "Spout To NDI" you can send this data over a local network to another computer, and then indeed it could be used as a camera surveillance network. (that's why i asked @hgy29 to support NDI directly in Gideros, to make this more effective, but that is still just a feature request).

    one major limitation of the gideros spout plugin that there are two ways how spout can receive the data (CPU and GPU i think) and gideros only supports CPU version while many apps support only the GPU way, and therefore my gideros app cannot send them the data even though that would be the point of this plugin.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • Thank you keszegh, I think it is very niche but could be fun to play with. I will try making two Gideros apps, a sender and a receiver.

    Likes: keszegh

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • that would be a nice sample code for the wiki indeed.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2023
    that's crazy they communicate :o
    first gideros app is called spout_emitter code:
    require "spout"
     
    -- source
    local source = Bitmap.new(Texture.new("gfx/1K-triangle_buble-diffuse.jpg"))
     
    -- spout
    local w, h = 320, 480
    local spoutEmitter = SpoutSender.new("GiderosAppX", w, h)
     
    local spoutRt = RenderTarget.new(w, h)
    spoutRt:draw(source)
    local rtbmp = Bitmap.new(spoutRt)
    stage:addChild(rtbmp)
     
    stage:addEventListener(Event.ENTER_FRAME, function(e)
    	spoutEmitter:sendTexture(spoutRt)
    end)
    Second app is called spout_receiver, code:
    require "spout"
     
    -- spout
    local spoutReceiver = SpoutReceiver.new("spoutReceiver")
    local spoutsenders = spoutReceiver:findSenders()
    for k, v in spoutsenders do
    	print(spoutsenders[k].name, spoutsenders[k].width, spoutsenders[k].height) -- GiderosAppX, 320, 480!!!
    end
     
    stage:addEventListener(Event.ENTER_FRAME, function(e)
    --	spoutReceiver:receiveTexture(spoutRt)
    --	spoutReceiver:receiveTexture(spoutReceiver)
    end)
    I run both apps in their respective Gideros Player and when I change the emitter and rerun both apps the values are updated on the receiver :o

    To be continued, God's willing...

    Likes: pie

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited December 2023
    cool, right?
    the point of it is to stream video data realtime, so your example would be better if it would keep changing the sent image (like rendering a particle on the rendertarget etc).

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • I cannot find how to get the sent texture :s
    local tex = Texture.new("gfx/1K-triangle_buble-diffuse.jpg")
     
    --local spoutreceiver = SpoutReceiver.new("spout receiver")
    local spoutreceiver = SpoutReceiver.new()
    local spoutsenders = spoutreceiver:findSenders()
    for k, v in spoutsenders do
    	print(spoutsenders[k].name, spoutsenders[k].width, spoutsenders[k].height)
    end
     
    local tex = spoutreceiver:receiveTexture(tex, spoutsenders[1].name, 320, 480) -- how to get tex from actual sender?
    print(tex) -- true
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • keszeghkeszegh Member
    edited December 2023
    i don't know the syntax but you use tex twice in two ways in the line
    local tex = spoutreceiver:receiveTexture(tex, spoutsenders[1].name, 320, 480)
    you should try
    local ok = spoutreceiver:receiveTexture(tex, spoutsenders[1].name, 320, 480)
    and see what tex is.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2023
    yes, that was some quick forum paste :p
    -- source
    local source = Texture.new("gfx/1K-triangle_buble-diffuse.jpg")
    local bmp = Bitmap.new(source)
    local w, h = source:getWidth(), source:getHeight()
     
    --local spoutreceiver = SpoutReceiver.new("spout receiver")
    local spoutreceiver = SpoutReceiver.new()
    local spoutsenders = spoutreceiver:findSenders()
    for k, v in spoutsenders do
    	print(spoutsenders[k].name, spoutsenders[k].width, spoutsenders[k].height)
    --	print(spoutsenders[k].texture)
    --	print(spoutreceiver:receiveTexture("spout sender", tex))
    end
     
    -- receive texture
    --local receivedtex = spoutreceiver:receiveTexture(spoutsenders[1].name)
    local bool, tex, w, h, x = spoutreceiver:receiveTexture(source, spoutsenders[1].name, 320, 480)
    print(bool, tex, w, h, x) -- true	spout sender	1024	1024	nil
    I don't know where the sender texture is stored :s

    This is the c++ side:
    static int receiveTexture(lua_State *L) {
    	GLCALL_INIT
    	void *s=g_getInstance(L,"SpoutReceiver",1);
    	TextureBase* texture = static_cast(g_getInstance(L,"TextureBase",2));
    	const char *mname=luaL_checkstring(L,3);
    	GLuint *tid=(GLuint *)gtexture_getInternalTexture(texture->data->gid)->getNative();
    	GLint oldFBO=0;
    	GLCALL glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
    	unsigned int tw=texture->data->width;
    	unsigned int th=texture->data->height;
    	char name[1024];
    	strcpy(name,mname);
    	lua_pushboolean(L,GidReceiveTexture(s,name,*tid,&tw,&th, oldFBO));
    	lua_pushstring(L,name);
    	lua_pushnumber(L,tw);
    	lua_pushnumber(L,th);
    	return 4;
    }
    first value is boolean, then a name, with a width and height, but where the texture itself is stored is unknown to my understanding :p
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • keszeghkeszegh Member
    edited December 2023
    here "s,name,*tid,&tw,&th, oldFBO" the 3rd is the texture.
    but probably the simplest is if @hgy29 tells us the syntax.
    i've found an old example in some folder, there i see something like this:
    r=SpoutReceiver.new()
    rtx=RenderTarget.new(512,512,true,{extend=false})
    --and later:
    r:receiveTexture(rtx)
    if this works then the received image is rendered on the rendertarget i guess.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2023
    Thank you for the help, this may help a lot, much appreciated :)

    I am trying to be a big boy and don't call on the captain o:)

    I am posting on this thread for future reference but you receive an email every time I post, so maybe I can create a new thread?

    EDIT: some more finding
    local v1, v2, v3, v4 = spoutreceiver:receiveTexture(source, "my tex")
    print(v1, v2, v3, v4) -- false	my tex	1024	1024
    v1, v2, v3, v4 = spoutreceiver:receiveTexture(source, spoutsenders[1].name)
    print(v1, v2, v3, v4) -- true	spout sender	1024	1024
    EDIT2: the doc https://spoutgl-site.netlify.app/#CClass:Spout:SendTexture

    EDIT3: it seems receiveTexture doesn't return the texture itself?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.