Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: How to clear part of texture buffer

  1. #1
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    How to clear part of texture buffer

    I have a FBO with one texture buffer attached. The idea is to have an atlas of billboards dynamically created and updated, as needed. When one of the sub images in the texture is going to be updated, I need to first clear the old content. What way is best to do that?

    One way is to disable depth tests and overwrite with a "blank" bitmap. But it would be inefficient.

    Another way would be to use glBlitFramebuffer(). Maybe it is possible to use with mask 0?

    Or maybe there is a much better solution available? Obviously, I could have one separate texture for each billboard, but I just have the feeling it would be more efficient with a single atlas.

  2. #2

  3. #3
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212
    Quote Originally Posted by Alfonse Reinheart View Post
    When you say "one texture buffer" do you mean a "buffer texture", or just a texture?
    Sorry, I don't know the definition exactly, but I have glGenTextures() + glTexImage2D() + glFramebufferTexture2D().

    So I would say I have a texture, "attached" to an image, and "bound" as a render target in the FBO.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    947
    You can attach the texture to a framebuffer, set the scissor in a way that it only covers the area you want to clear using glScissor, then do glClear/glClearBuffer to clear the texture attached to the FBO.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  5. #5
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212
    Thanks, this was exactly what I was looking for!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •