Author Topic: Dynamic texture - setRenderTarget  (Read 4390 times)

Offline zbych

  • int
  • **
  • Posts: 75
    • View Profile
Dynamic texture - setRenderTarget
« on: February 17, 2012, 09:57:44 pm »
I wanted to write an application that uses a dynamically changing textures - just need to copy the contents of one texture to another in the desired location.
I tried to use the opportunity to render to texture, but I found a problem. I do not know whether it is normal for OpenGL ES, but the problem is that during the next call
onDrawFrame the framebuffer holding dynamic texture contains garbage and is useless without clearing and re-rendering it again, but I need to keep the contents of this texture and draw another items on it. I tested it on three devices and only on one of them texture has not been littered between subsequent calls onDrawFrame.

Is any solution to this, or other way to generate dynamic textures without having to load them into GPU memory?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Dynamic texture - setRenderTarget
« Reply #1 on: February 17, 2012, 10:26:09 pm »
Quote
...the framebuffer holding dynamic texture...
I don't get it... ???

Offline zbych

  • int
  • **
  • Posts: 75
    • View Profile
Re: Dynamic texture - setRenderTarget
« Reply #2 on: February 17, 2012, 10:29:40 pm »
Sorry i was thinking about buffer holding texture data not framebuffer

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Dynamic texture - setRenderTarget
« Reply #3 on: February 17, 2012, 10:31:13 pm »
I still don't get the problem...you have assigned a render target to a frame buffer. You then render into that texture/render target. And then happens..what?

Offline zbych

  • int
  • **
  • Posts: 75
    • View Profile
Re: Dynamic texture - setRenderTarget
« Reply #4 on: February 17, 2012, 11:58:16 pm »
I want to render to this texture again, without clearing its data. If I clear it every frame and render to it then everything looks ok, but if I don't clear it (don't call framebuffer.clear() with this texture as render target) then I get dirty texture on input - it is filled with trash and I don't know why.
Of course i clear it when it is first time created, but i don't want to do it every rendered frame.
For example I have rendered letter "A" to this texture and in next animation frame I want to add "B", if I clear this texture then I have to render both letters, but I want to add just new letter - imagine when there are 1000 letters and you want to add 1, if you clear this texture then you have to render 1000 previous letters to add 1 new on the end. I want to avoid it.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Dynamic texture - setRenderTarget
« Reply #5 on: February 18, 2012, 12:00:21 am »
Try to clear the depth buffer only by using FrameBuffer.clearZBufferOnly();...maybe that helps.

Offline zbych

  • int
  • **
  • Posts: 75
    • View Profile
Re: Dynamic texture - setRenderTarget
« Reply #6 on: February 18, 2012, 12:23:57 am »
I have already tried this. Texture looks better but it is not enough.
Thanks for help but it looks like I have to find another way :(


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Dynamic texture - setRenderTarget
« Reply #7 on: February 18, 2012, 12:51:48 am »
Render to texture in OpenGL ES 1.x isn't working too well on some devices. If possible, you might want to try OpenGL ES 2.0 support instead (in case you haven't already...) as it uses FBOs for this, which are more compatible. Maybe that helps.

Offline zbych

  • int
  • **
  • Posts: 75
    • View Profile
Re: Dynamic texture - setRenderTarget
« Reply #8 on: February 18, 2012, 01:12:57 am »
It was from begining in GL ES 2.0. I have just tested this on GL ES 1.x and there was black texture, no rendering output .