Package graphics
Class Framebuffer
java.lang.Object
graphics.Framebuffer
This class is heavily inspired from TheCherno's Hazel Engine's Framebuffer API
An encapsulation of an OpenGL Framebuffer
- Author:
- VoxelRifts
-
Constructor Summary
ConstructorDescriptionFramebuffer
(int width, int height, FramebufferSpec spec) Default Framebuffer constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
Binds the framebuffervoid
Copies all data from the color texture attachments of this framebuffer to the texture attachments of the default Framebuffer.void
Copies all data from the ALL texture attachments of this framebuffer to the texture attachments of the default Framebuffer.static void
clean()
Deletes all Framebuffersstatic Framebuffer
Factory method to create an instance that manages the default framebufferstatic Framebuffer
Factory method to create an instance that is half the size of the screen and has one simple color attachmentstatic Framebuffer
Factory method to create an instance that has one simple color attachmentvoid
delete()
Deletes the texture attachments and the framebuffergetColorAttachment
(int i) Get a color texture attachment id from the framebufferGet the depth attachment texture from this framebufferint
Get the height of this Framebufferint
getWidth()
Get the width of this Framebufferboolean
Checks if the fbo is a wrapper around the default one.void
resize
(int width, int height) Resize the Framebuffer to a specific size it will regenerate the entire framebufferstatic void
Resize all Framebuffers created via the createWithColorAttachment() or createHalfResWithColorAttachment() methodsstatic void
unbind()
Unbinds the framebuffer i.e.
-
Constructor Details
-
Framebuffer
Default Framebuffer constructor- Parameters:
width
- int: width of the fboheight
- int: height of the fbospec
- FramebufferSpec: Specification of the framebuffer
-
-
Method Details
-
createDefault
Factory method to create an instance that manages the default framebuffer- Returns:
- Framebuffer
-
createWithColorAttachment
Factory method to create an instance that has one simple color attachment- Returns:
- Framebuffer
-
createHalfResWithColorAttachment
Factory method to create an instance that is half the size of the screen and has one simple color attachment- Returns:
- Framebuffer
-
resizeAll
Resize all Framebuffers created via the createWithColorAttachment() or createHalfResWithColorAttachment() methods -
unbind
public static void unbind()Unbinds the framebuffer i.e. binds the default framebuffer -
clean
public static void clean()Deletes all FramebuffersCalled after the X is pressed
-
isDefault
public boolean isDefault()Checks if the fbo is a wrapper around the default one. Required because created wrapper has no attachments stored in colorAttachmentTextures- Returns:
- if the framebuffer instance is a wrapper around the
-
getColorAttachment
Get a color texture attachment id from the framebuffer- Parameters:
i
- index of the texture attachment required- Returns:
- the color attachment texture id at the index
-
getDepthAttachment
Get the depth attachment texture from this framebuffer- Returns:
- the depth attachment texture id
-
blitColorBuffersToScreen
public void blitColorBuffersToScreen()Copies all data from the color texture attachments of this framebuffer to the texture attachments of the default Framebuffer. OpenGL provides a function, glBlitFramebuffer for this -
blitEntireFboToScreen
public void blitEntireFboToScreen()Copies all data from the ALL texture attachments of this framebuffer to the texture attachments of the default Framebuffer. OpenGL provides a function, glBlitFramebuffer for this -
resize
public void resize(int width, int height) Resize the Framebuffer to a specific size it will regenerate the entire framebuffer- Parameters:
width
- int: new widthheight
- int new height
-
bind
public void bind()Binds the framebuffer -
delete
public void delete()Deletes the texture attachments and the framebuffer -
getWidth
public int getWidth()Get the width of this Framebuffer- Returns:
- width of the Framebuffer
-
getHeight
public int getHeight()Get the height of this Framebuffer- Returns:
- height of the Framebuffer
-