Rendering a Android View onto a texture

Started by nathan, April 29, 2013, 03:27:00 AM

Previous topic - Next topic

nathan

I would like to have a standard android View (such as Button), and render its graphics onto a texture.  I can create a bitmap, create a canvas for the bitmap, and have the view draw onto the bitmap through the canvas.  Then, I can take the bitmap and turn it into a texture.  This works fine. However I am having difficulties with updating that texture later (button was pressed, text changed, etc).  Of course I cannot create a new texture each time it changes.

I thought the solution was to change the render target of the framebuffer to the texture, and then blit the bitmap onto it.  However, this doesn't seem to work.

I think the problem is that I am using OpenGL ES 1.0.  What is the minimum version of OpenGL ES I need to do this?  What is the optimum way of doing this?  One framebuffer per texture? Or one framebuffer that gets passed around?  The javadoc says that blit(int[]) is slow, is there an alternative without having to create a new texture every time the android view changes?

EgonOlsen

All the ways that you mentioned require upload of new texture data, which is slow. Why don't you combine the GUI    elements directly with the GL output. I've seen people doing this, so it has to be possible albeit i would never do this myself. Which leads me to another suggestion: Don't do this at all and render all GUI elements by yourself. For simple buttons, this is pretty easy to achieve with blitted textures and a simple handler for the touch events.

nathan

I want the buttons to appear at an angle, behind GL objects, etc.  How would I do this without it being a texture?

EgonOlsen

No idea. Personally, i would just ditch Android's GUI classes then and do my own stuff.