Interface AdvancedFbo
- All Superinterfaces:
AutoCloseable,org.lwjgl.system.NativeResource
- All Known Implementing Classes:
AdvancedFboImpl,VanillaAdvancedFboWrapper
A framebuffer that has more capabilities than the vanilla Minecraft RenderTarget.
In order to resize, NativeResource.free() must be called and a new framebuffer should be created.
Multiple color buffers of different types and depth attachments can be added.
Draw buffers are set automatically, but the default can be retrieved with getDrawBuffers()
to effectively reset it. The draw buffers are set once by default and must be reset back if modified.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA builder used to attach buffers to anAdvancedFbo. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(boolean setViewport) Binds this framebuffer for read and draw requests.voidbindDraw(boolean setViewport) Binds this framebuffer for draw requests.voidbindRead()Binds this framebuffer for read requests.voidclear()Clears the buffers in this framebuffer.static AdvancedFbo.Buildercopy(com.mojang.blaze3d.pipeline.RenderTarget parent) Creates a copy of the providedRenderTarget.static AdvancedFbo.Buildercopy(AdvancedFbo parent) Creates a copy of the providedAdvancedFbo.voidcreate()Creates the framebuffer and all attachments.default voiddraw()Draws this framebuffer to the screen.intgetColorAttachment(int attachment) Checks the attachments for the specified slot.intdefault AdvancedFboRenderAttachmentgetColorRenderAttachment(int attachment) Retrieves the attachment for the specified slot.default AdvancedFboTextureAttachmentgetColorTextureAttachment(int attachment) Retrieves the attachment for the specified slot.default AdvancedFboRenderAttachmentRetrieves a depth buffer render attachment.default AdvancedFboTextureAttachmentRetrieves a depth buffer texture attachment.int[]intintgetId()static AdvancedFboGets the main framebuffer.intgetWidth()booleanhasColorAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer.booleandefault booleanisColorRenderAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a render attachment.default booleanisColorTextureAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a texture attachment.default booleandefault booleandefault booleandefault booleanisMutableColorTextureAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a mutable texture attachment.default voidresolveToAdvancedFbo(AdvancedFbo target) Resolves this framebuffer to the provided advanced framebuffer as the target.default voidresolveToAdvancedFbo(AdvancedFbo target, int mask, int filtering) Resolves this framebuffer to the provided advanced framebuffer as the target.default voidresolveToFbo(int id, int width, int height, int mask, int filtering) Resolves this framebuffer to the framebuffer with the specified id as the target.default voidresolveToFramebuffer(com.mojang.blaze3d.pipeline.RenderTarget target) Resolves this framebuffer to the provided minecraft framebuffer as the target.default voidresolveToFramebuffer(com.mojang.blaze3d.pipeline.RenderTarget target, int mask, int filtering) Resolves this framebuffer to the provided minecraft framebuffer as the target.default voidResolves this framebuffer to the window framebuffer as the target.default voidresolveToScreen(int mask, int filtering) Resolves this framebuffer to the window framebuffer as the target.default voidsetColorAttachmentTexture(int attachment, int textureId) Updates the 2D texture attachment reference for the specified slot.default voidsetColorAttachmentTexture(int attachment, int textureId, int layer) Updates the texture attachment reference for the specified slot.default voidsetDepthAttachmentTexture(int textureId) Updates the 2D depth texture attachment reference for the specified slot.default voidsetDepthAttachmentTexture(int textureId, int layer) Updates the depth texture attachment reference for the specified slot.com.mojang.blaze3d.pipeline.RenderTargetstatic voidunbind()Binds the main Minecraft framebuffer for writing and reading.static voidBinds the main Minecraft framebuffer for drawing.static voidBinds the main Minecraft framebuffer for reading.static AdvancedFbo.BuilderwithSize(int width, int height) Creates a newAdvancedFbowith the provided width and height.Methods inherited from interface org.lwjgl.system.NativeResource
close, free
-
Method Details
-
create
void create()Creates the framebuffer and all attachments. -
clear
void clear()Clears the buffers in this framebuffer. -
bind
void bind(boolean setViewport) Binds this framebuffer for read and draw requests.- Parameters:
setViewport- Whether to set the viewport to fit the bounds of this framebuffer
-
bindRead
void bindRead()Binds this framebuffer for read requests. -
bindDraw
void bindDraw(boolean setViewport) Binds this framebuffer for draw requests.- Parameters:
setViewport- Whether to set the viewport to fit the bounds of this framebuffer
-
getMainFramebuffer
Gets the main framebuffer.- Returns:
- main framebuffer
-
unbind
static void unbind()Binds the main Minecraft framebuffer for writing and reading. -
unbindRead
static void unbindRead()Binds the main Minecraft framebuffer for reading. -
unbindDraw
static void unbindDraw()Binds the main Minecraft framebuffer for drawing. -
draw
default void draw()Draws this framebuffer to the screen. -
resolveToFbo
default void resolveToFbo(int id, int width, int height, int mask, int filtering) Resolves this framebuffer to the framebuffer with the specified id as the target.- Parameters:
id- The id of the framebuffer to copy intowidth- The width of the framebuffer being copied intoheight- The height of the framebuffer being copied intomask- The buffers to copy into the provided framebufferfiltering- The filter to use if this framebuffer and the provided framebuffer are different sizes
-
resolveToAdvancedFbo
Resolves this framebuffer to the provided advanced framebuffer as the target.- Parameters:
target- The target framebuffer to copy data into
-
resolveToAdvancedFbo
Resolves this framebuffer to the provided advanced framebuffer as the target.- Parameters:
target- The target framebuffer to copy data intomask- The buffers to copy into the provided framebufferfiltering- The filter to use if this framebuffer and the provided framebuffer are different sizes
-
resolveToFramebuffer
default void resolveToFramebuffer(com.mojang.blaze3d.pipeline.RenderTarget target) Resolves this framebuffer to the provided minecraft framebuffer as the target.- Parameters:
target- The target framebuffer to copy data into
-
resolveToFramebuffer
default void resolveToFramebuffer(com.mojang.blaze3d.pipeline.RenderTarget target, int mask, int filtering) Resolves this framebuffer to the provided minecraft framebuffer as the target.- Parameters:
target- The target framebuffer to copy data intomask- The buffers to copy into the provided framebufferfiltering- The filter to use if this framebuffer and the provided framebuffer are different sizes
-
resolveToScreen
default void resolveToScreen()Resolves this framebuffer to the window framebuffer as the target. -
resolveToScreen
default void resolveToScreen(int mask, int filtering) Resolves this framebuffer to the window framebuffer as the target.- Parameters:
mask- The buffers to copy into the provided framebufferfiltering- The filter to use if this framebuffer and the provided framebuffer are different sizes
-
getId
int getId()- Returns:
- The id of this framebuffer or -1 if it has been deleted
-
getWidth
int getWidth()- Returns:
- The width of this framebuffer
-
getHeight
int getHeight()- Returns:
- The height of this framebuffer
-
getColorAttachments
int getColorAttachments()- Returns:
- The amount of color attachments in this framebuffer
-
getClearMask
int getClearMask()- Returns:
- The mak used while clearing the buffer
-
getDrawBuffers
int[] getDrawBuffers()- Returns:
- The names of the default draw buffer state
-
hasColorAttachment
boolean hasColorAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer.- Parameters:
attachment- The attachment to check- Returns:
- Whether there is a valid attachment in the specified slot
-
hasDepthAttachment
boolean hasDepthAttachment()- Returns:
- Whether there is a depth attachment added to this framebuffer
-
getColorAttachment
Checks the attachments for the specified slot. If the amount of attachments is unknown, usehasColorAttachment(int)to verify before calling this.- Parameters:
attachment- The attachment to get- Returns:
- The attachment in the specified attachment slot
- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot
-
isColorTextureAttachment
default boolean isColorTextureAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a texture attachment.- Parameters:
attachment- The attachment to check- Returns:
- Whether there is a valid attachment in the specified slot
-
isMutableColorTextureAttachment
default boolean isMutableColorTextureAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a mutable texture attachment.- Parameters:
attachment- The attachment to check- Returns:
- Whether there is a valid attachment in the specified slot
-
isColorRenderAttachment
default boolean isColorRenderAttachment(int attachment) Checks to see if the provided attachment has been added to this framebuffer and is a render attachment.- Parameters:
attachment- The attachment to check- Returns:
- Whether there is a valid attachment in the specified slot
-
getColorTextureAttachment
Retrieves the attachment for the specified slot. If the attachment is not known to be anAdvancedFboTextureAttachment, useisColorTextureAttachment(int)before calling this.- Parameters:
attachment- The attachment to get- Returns:
- The texture attachment in the specified attachment slot
- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboTextureAttachment
-
setColorAttachmentTexture
default void setColorAttachmentTexture(int attachment, int textureId) Updates the 2D texture attachment reference for the specified slot. If the attachment is not known to be anAdvancedFboMutableTextureAttachment, useisMutableColorTextureAttachment(int)before calling this.- Parameters:
attachment- The attachment to modifytextureId- The id of the texture to draw into- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboMutableTextureAttachment
-
setColorAttachmentTexture
default void setColorAttachmentTexture(int attachment, int textureId, int layer) Updates the texture attachment reference for the specified slot. if the attachment is not known to be an
AdvancedFboMutableTextureAttachment, useisMutableColorTextureAttachment(int)before calling this.The framebuffer must be bound before calling this
- Parameters:
attachment- The attachment to modifytextureId- The id of the texture to draw intolayer- The texture layer to attach. For cubemaps this is the attachment face- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboMutableTextureAttachment
-
getColorRenderAttachment
Retrieves the attachment for the specified slot. If the attachment is not known to be anAdvancedFboRenderAttachment, useisColorRenderAttachment(int)before calling this.- Parameters:
attachment- The attachment to get- Returns:
- The render attachment in the specified attachment slot
- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboRenderAttachment
-
getDepthAttachment
AdvancedFboAttachment getDepthAttachment()- Returns:
- The depth attachment of this framebuffer
- Throws:
IllegalArgumentException- If there is no depth attachment in this framebuffer
-
isDepthTextureAttachment
default boolean isDepthTextureAttachment()- Returns:
- Whether a depth texture attachment has been added to this framebuffer
-
isDepthMutableTextureAttachment
default boolean isDepthMutableTextureAttachment()- Returns:
- Whether a mutable depth texture attachment has been added to this framebuffer
-
isDepthRenderAttachment
default boolean isDepthRenderAttachment()- Returns:
- Whether a depth render attachment has been added to this framebuffer
-
getDepthTextureAttachment
Retrieves a depth buffer texture attachment. If the attachment is not known to be aAdvancedFboTextureAttachment, useisDepthTextureAttachment()before calling this.- Returns:
- The texture attachment in the specified attachment slot
- Throws:
IllegalArgumentException- If there is no depth attachment in this framebuffer, or it is not anAdvancedFboTextureAttachment
-
setDepthAttachmentTexture
default void setDepthAttachmentTexture(int textureId) Updates the 2D depth texture attachment reference for the specified slot. If the attachment is not known to be anAdvancedFboMutableTextureAttachment, useisMutableColorTextureAttachment(int)before calling this.- Parameters:
textureId- The id of the texture to draw into- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboMutableTextureAttachment
-
setDepthAttachmentTexture
default void setDepthAttachmentTexture(int textureId, int layer) Updates the depth texture attachment reference for the specified slot. If the attachment is not known to be an
AdvancedFboMutableTextureAttachment, useisMutableColorTextureAttachment(int)before calling this.The framebuffer must be bound before calling this
- Parameters:
textureId- The id of the texture to draw intolayer- The texture layer to attach. For cubemaps this is the attachment face- Throws:
IllegalArgumentException- If there is no attachment in the specified attachment slot, or it is not anAdvancedFboMutableTextureAttachment
-
getDepthRenderAttachment
Retrieves a depth buffer render attachment. If the attachment is not known to be aAdvancedFboRenderAttachment, useisDepthRenderAttachment()before calling this.- Returns:
- The render attachment in the specified attachment slot
- Throws:
IllegalArgumentException- If there is no depth attachment in this framebuffer, or it is not anAdvancedFboRenderAttachment
-
toRenderTarget
com.mojang.blaze3d.pipeline.RenderTarget toRenderTarget()- Returns:
- A
RenderTargetthat uses this advanced fbo as the target
-
withSize
Creates a newAdvancedFbowith the provided width and height.- Parameters:
width- The width of the canvasheight- The height of the canvas- Returns:
- A builder to construct a new FBO
-
copy
Creates a copy of the providedAdvancedFbo.- Parameters:
parent- The parent to copy attachments from- Returns:
- A builder to construct a new FBO
-
copy
Creates a copy of the providedRenderTarget.- Parameters:
parent- The parent to copy attachments from- Returns:
- A builder to construct a new FBO
-