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 2 of 2

Thread: Check color encoding in the default framebuffer draw buffer for SRGB

  1. #1
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    85

    Check color encoding in the default framebuffer draw buffer for SRGB

    I am in the process of implementing sRGB space in my application.

    From what I read here, here, here and here I should operate in linear RGB (LRGB) space for the whole pipeline and I dont have to care about any gamma correction since OpenGL will take care about it for me given I enable GL_FRAMEBUFFER_SRGB​ and the image is either GL_SRGB8 or GL_SRGB8_ALPHA8.

    So my idea is to be sure I submit inputs in LRGB space and then I render my final texture (doing depth peeling) on the default framebuffer that will take care of porting my colors to the SRGB space so that I will see them on LRGB on my monitor.

    Ok, now I want to check the default draw buffer of the default framebuffer.

    Code :
    int[] drawBuffer = new int[1];
     
                gl3.glGetIntegerv(GL3.GL_DRAW_BUFFER, drawBuffer, 0);
     
                System.out.println("draw buffer " + (drawBuffer[0] == GL3.GL_BACK ? "BACK " : drawBuffer[0]));
    this confirms my draw buffer is GL_BACK, now I want to check the color encoding

    Code :
    int[] framebufferAttachmentParameter = new int[1];
     
                gl3.glGetFramebufferAttachmentParameteriv(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_BACK,
                        GL3.GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, framebufferAttachmentParameter, 0);

    but glGetFramebufferAttachmentParameteriv fails:

    > glGetError() returned the following error codes after a call to glGetFramebufferAttachmentParameteriv(<int> 0x8CA9, <int> 0x405, <int> 0x8210, <[I>, <int> 0x0): GL_INVALID_ENUM ( 1280 0x500)
    Reading here they say

    If the default framebuffer is bound to target then attachment must be one of GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT, or GL_BACK_RIGHT
    But my code say my draw buffer is GL_BACK. Reading here they say the GL_BACK is just an alias that indicates both GL_BACK_LEFT and GL_BACK_RIGHT if I do stereotic rendering.

    So my questions are:

    - am I right assuming that I am writing to GL_BACK_LEFT given my draw buffer returns GL_BACK

    - how can I check if stereotic rendering is on/off? Of course since I dont know even how to turn it on, I assume it is off. But is something I do by just enabling both GL_BACK/FRONT_LEFT/RIGHT buffers or something else?

    - can I turn on SRGB space on the default draw buffer of the default framebuffer?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,924
    am I right assuming that I am writing to GL_BACK_LEFT given my draw buffer returns GL_BACK
    Yes, but:

    Reading here they say the GL_BACK is just an alias that indicates both GL_BACK_LEFT and GL_BACK_RIGHT if I do stereotic rendering.
    Yes, it is an alias. However, as the page you linked to indicated, "These are only allowed in glDrawBuffer​ (not glDrawBuffers​; note the "s") and glReadBuffer​." Since glGetFramebufferAttachmentParameteriv is not one of those functions, it is not allowed there. You must instead use a specific buffer name (GL_BACK_LEFT or GL_BACK_RIGHT)

    how can I check if stereotic rendering is on/off?
    That's not really something you should have to check. If you don't ask for it at context creation time, then it's not on.

    can I turn on SRGB space on the default draw buffer of the default framebuffer?
    Only by creating a rendering context who's images use the sRGB colorspace.

Tags for this Thread

Posting Permissions

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