Author Topic: Clear framebuffer and stop rendering  (Read 562 times)

Offline ap

  • byte
  • *
  • Posts: 12
    • View Profile
Clear framebuffer and stop rendering
« on: May 06, 2015, 09:11:01 am »
Hello

I'm trying to switch visibility of the OpenGL context quite fast, so in order to turn the visibility off I'm trying to clear the framebuffer and then stop rendering (so the onDrawFrame wouldn't be called and the result will be a fixed black screen, until resumed).
If I'm switching the visibility of the view, it destroys the OpenGL context, and I would like it to preserve if because pausing and resuming can occur really fast.

I noticed there isn't really a way to clear all buffers (due to triple-buffering on my mobile GPU, I need to call clear() on my framebuffer 3 times from onDrawFrame() before  the view is actually cleared).
I could clear the framebuffer in onDrawFrame() and then return (so nothing is drawn), but then the OpenGL thread still remains active and it isn't really necessary.

Is there a good way for doing something like that - clearing framebuffer and stop rendering?

Thanks
AP


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Clear framebuffer and stop rendering
« Reply #1 on: May 06, 2015, 09:11:07 pm »
I'm not sure. I had a similar problem once and didn't come up with a proper solution. Then again, i haven't looked for one very long...

Maybe clearing the buffer multiple times before stopping the rendering will do the trick? Like 1st clear, buffer switch, 2nd clear, buffer switch, 3rd clear, buffer switch...stop?

Offline ap

  • byte
  • *
  • Posts: 12
    • View Profile
Re: Clear framebuffer and stop rendering
« Reply #2 on: May 10, 2015, 01:57:57 pm »
That's exactly what I did eventually... it worked. I was hoping for a more elegant solution :)