Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FrameBuffer to handle multiple color attachments #227

Merged
merged 10 commits into from
Jan 28, 2024

Conversation

LeHaine
Copy link
Member

@LeHaine LeHaine commented Jan 27, 2024

FrameBuffer

The previous FrameBuffer implementation allowed only a single color attachment and assumed you were using it directly. The new implementation will allow a list of a new object ColorAttachment which takes the original parameters.

Old

val fbo = FrameBuffer(250, 250, hasDepth = false, hasStencil = false, hasPackedDepthStencil = false, format = Pixmap.Format.RGBA8888, minFilter = TexMinFilter.LINEAR, magFilter = TexMagFilter.LINEAR)

batch.draw(fbo.colorBufferTexture, 0f, 0f)

This way can still be used. No breaking changes regarding usage.

New

val fbo = FrameBuffer(250, 250, hasDepth = false, hasStencil = false, hasPackedDepthStencil = false, colorAttachments = listOf(ColorAttachment(format = Pixmap.Format.RGBA8888, minFilter = TexMinFilter.LINEAR, magFilter = TexMagFilter.LINEAR, wrap = TexWrap.CLAMP_TO_EDGE)))

batch.draw(fbo.textures[0], 0f, 0f)

colorAttachments will default to a single color attachment listOf(ColorAttachment()).
FrameBuffer.textures is a list that will contain the textures for each color attachment on the FBO.

GL

Added the GL.drawBuffers(size: Int, buffers: IntBuffer) function
Added the GL.clearBuffer[fuiv]() functions

Shaders

Updated GlslGenerator to support the use of gl_FragData[n] inside fragment shaders. This will generate the correct out variables if using GLSL 3.0+ if the gl_FragColor or gl_FragData[n] is referenced anyway in the shader code.
Added support for GL_EXT_DrawBuffers for version GLES 2.0

gl: add new drawBuffers(size, buffer) function

scenegraph: tweak FrameBuffer nodes to handle new way of instantiating a FrameBuffer and using it's texture

samples: update FrameBuffer usage
@LeHaine LeHaine added enhancement New feature or request graphics Graphics related issues labels Jan 27, 2024
@LeHaine LeHaine marked this pull request as ready for review January 28, 2024 16:20
@LeHaine LeHaine merged commit e5fd060 into master Jan 28, 2024
1 check passed
@LeHaine LeHaine deleted the frame-buffer-multi-attachments branch January 28, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request graphics Graphics related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant