PDA

View Full Version : OpenGL Compute modify GL_BACK



Christoph.LGDV
11-28-2016, 01:46 AM
Hi,

I want to display the G-BufferContents on screen (or anything at all) using a GL Compute Shader.


Is it by now possible to bind the backbuffer as an image?
Or is there an alternative solution?


Best Regards
Christoph

GClements
11-28-2016, 07:30 AM
Is it by now possible to bind the backbuffer as an image?

No. Only textures may be bound as images, so you'll need to render or blit the texture to the default framebuffer.

Note that while EGL allows you to bind an EGLSurface as a texture, this only works for pbuffer surfaces, not window surfaces.

john_connor
11-28-2016, 12:06 PM
I want to display the G-BufferContents on screen (or anything at all) using a GL Compute Shader.

Is it by now possible to bind the backbuffer as an image?
Or is there an alternative solution?

i assume your "Gbuffer" is a framebuffer object with some texture or renderbuffer attachments
you dont need compute shaders for that, just blit your (G-)framebuffer content into the default framebuffer (screen)

https://www.opengl.org/sdk/docs/man/html/glBlitFramebuffer.xhtml

before you call that, bind your G-buffer as source for read operations and the default framebuffer (screen) as destination for draw operations:

glBindFramebuffer(GL_READ_FRAMEBUFFER, gbuffer);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

then specify the attachment you want to read from, e.g.:

glReadBuffer(GL_COLOR_ATTACHMENT0);

then call glBlitFramebuffer(...) to copy the G-framebuffer content into the default framebuffer (screen)

Christoph.LGDV
11-30-2016, 12:42 AM
Thank you for your replies.

I was wondering if there was a hack, similar to the Direct3D solution where i can get the required pointers.

@john_connor why would I want to blit a GBuffer to my framebuffer, it is sensible to render the deferred lighting directly to framebuffer0