Results 1 to 7 of 7

Thread: clear a GL_R32UI renderbuffer with an int

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2010
    Posts
    16

    clear a GL_R32UI renderbuffer with an int

    Hi,
    I have trouble finding anything on how to clear an integer renderbuffer.
    glClear(GL_COLOR_BUFFER_BIT) does set it to zero, but how can I set it to a different value?
    Thanks,
    Soren

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: clear a GL_R32UI renderbuffer with an int

    Take a look at glClearBuffer.

  3. #3
    Senior Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    890

    Re: clear a GL_R32UI renderbuffer with an int

    Or glClearColorIiEXT from EXT_texture_integer.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2010
    Posts
    16

    Re: clear a GL_R32UI renderbuffer with an int

    Thanks guys,
    I have had a look at glClearBuffer but am unable to find a suitable example. Also the documentation does not specify integer use outside of depth and and stencil buffers.
    Did not have any luck with the extensions either so may just draw a textured quad in stead.
    Thanks
    Soren

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: clear a GL_R32UI renderbuffer with an int

    Just use the following code:

    unsigned int clear_value = put_here_your_clear_value;
    glClearBufferuiv(GL_COLOR, 0, &clear_value);

    Here GL_COLOR and 0 specifies that the first color buffer has to be cleared with the specified clear value.
    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/

  6. #6
    Junior Member Newbie
    Join Date
    Jul 2010
    Posts
    16

    Re: clear a GL_R32UI renderbuffer with an int

    That works! Thanks so much - I skipped over glClearBuffer too fast.
    Thanks again!

    Soren

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: clear a GL_R32UI renderbuffer with an int

    Before you try out my previous code, sorry, but I wrote it incorrectly, because the clear value must always be a vec4 value (even though you need only the red component), so the code should be like this:


    unsigned int clear_value[4] = { put_here_your_clear_value, 0, 0, 0 };
    glClearBufferuiv(GL_COLOR, 0, clear_value);
    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/

Similar Threads

  1. Renderbuffer with int values
    By missmini in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-03-2017, 08:45 AM
  2. Replies: 0
    Last Post: 12-05-2013, 11:17 PM
  3. srgb Renderbuffer?
    By Hollis in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-11-2011, 08:55 AM
  4. FBO renderbuffer how it works
    By OGNewBee in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-24-2011, 01:01 AM
  5. how to present the renderbuffer?
    By killpig in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-20-2010, 12:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean