Author Topic: Rendering a Android View onto a texture  (Read 2062 times)

Offline nathan

  • byte
  • *
  • Posts: 15
    • View Profile
Rendering a Android View onto a texture
« on: April 29, 2013, 03:27:00 am »
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?
« Last Edit: April 29, 2013, 03:38:51 am by nathan »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Rendering a Android View onto a texture
« Reply #1 on: April 29, 2013, 12:35:55 pm »
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.

Offline nathan

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Rendering a Android View onto a texture
« Reply #2 on: April 29, 2013, 07:09:57 pm »
I want the buttons to appear at an angle, behind GL objects, etc.  How would I do this without it being a texture?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Rendering a Android View onto a texture
« Reply #3 on: April 30, 2013, 07:04:08 pm »
No idea. Personally, i would just ditch Android's GUI classes then and do my own stuff.