Jump to content

Dynamic Texture as GUI Image


Pryme8
 Share

Recommended Posts

Is it possible to pass a texture, a dynamic texture, or even better a material to a GUI button?

I know I could convert the texture to an image, but I was hoping to skip a step.

texture.update()
            
            /*-- Create Image --*/
            var canvas = document.createElement('canvas')
            canvas.width = size.x, canvas.height = size.y
            
            var tCtx = canvas.getContext('2d')
            var iDat = ctx.getImageData(0,0,size.x, size.y)
        
            tCtx.putImageData(iDat, 0,0)
            
            var image = new Image()
            image.id = "GUI-Image"
            image.src = canvas.toDataURL()
            
            texture.rawImage = image;


Is what I am doing right now.

Ideally I would want to be able to assign a rtt, to a Image on a button on the GUI.  With the intent of raymarching some GUI elements but using the GUI's structure to organize and deal with mouse interaction. 

Link to comment
Share on other sites

GUI is canvas based so there is no webgl involved. So no material or texture.

So you need to read pixels (texture.readPixels) and use that to draw in your canvas. Should not be a problem if you don't that too much as it involves GPU->CPU memory transfer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...