Check color encoding in the default framebuffer draw buffer for SRGB

621 views Asked by At

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.

        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

        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( 0x8CA9, 0x405, 0x8210, <[I>, 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?

1

There are 1 answers

0
elect On

I got an answer on the opengl forums, I think it can be useful for anyone visiting this question if I leave this here

https://www.opengl.org/discussion_boards/showthread.php/185198-Check-color-encoding-in-the-default-framebuffer-draw-buffer-for-SRGB?p=1263059#post1263059