Class FrameBufferObject

  • Direct Known Subclasses:
    GBuffer

    public class FrameBufferObject
    extends Object
    Class that represents a frame buffer object in opengl
    Author:
    Darius Dinger
    • Constructor Detail

      • FrameBufferObject

        public FrameBufferObject​(int width,
                                 int height,
                                 boolean multisampled)
        Creates new framebuffer in opengl and attaching first color buffer (color buffer 0) and depth buffer
        Parameters:
        width - Horizontal resolution of the fbo in pixels
        height - Vertical resolution of the fbo in pixels
        multisampled - Should fbo use multisampling
    • Method Detail

      • blitToFbo

        public final void blitToFbo​(FrameBufferObject out,
                                    int buffers)
        Blitting/writing color and depth information from this fbo into another fbo
        Parameters:
        out - Output fbo to blit in
        buffers - Wich buffers to blit (GL_DEPTH_BUFFER_BIT, GL_COLOR_BUFFER_BIT)
      • blitToScreen

        public final void blitToScreen()
        Blitting this fbo onto the glfw window
      • bind

        public final void bind​(int readAttachment)
        Binding framebuffer as draw framebuffer and bind all color buffers. Sets glViewport to fbo dimension
        Parameters:
        readAttachment - Color attachment to bind as read buffer
      • unbind

        public final void unbind()
        Unbing framebuffer (bind 0) and reset glViewport to window dimension
      • getDepthAttachment

        public final int getDepthAttachment()
        Returning the id of the depth texture, if multisampling is disabled. If multisampling is enabled, returning the id of the depth buffer
        Returns:
        Id of the depth texture/buffer
      • getColorAttachment0

        public final int getColorAttachment0()
        Returning the id of the color attachment texture, if multisampling is disabled. If multisampling is enabled, returning the id of the color attachment buffer
        Returns:
        Id of the color attachment 0 texture/renderbuffer