Class PostProcessor
java.lang.Object
gaiasky.util.gdx.contrib.postprocess.PostProcessor
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
-
Field Summary
Modifier and TypeFieldDescriptionstatic PostProcessor
static boolean
Enable pipeline state queries: beware the pipeline can stall! -
Constructor Summary
ConstructorDescriptionPostProcessor
(IPostProcessor.RenderType rt, boolean useDepth, boolean useAlphaChannel, boolean use32Bits) Construct a new PostProcessor with FBO dimensions set to the size of the screenPostProcessor
(IPostProcessor.RenderType rt, int fboWidth, int fboHeight, boolean hasDepth, boolean useAlphaChannel, boolean use32Bits, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Construct a new PostProcessor with the given parameters, defaulting to TextureWrap.ClampToEdge as texture wrap modePostProcessor
(IPostProcessor.RenderType rt, int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer, com.badlogic.gdx.graphics.Texture.TextureWrap u, com.badlogic.gdx.graphics.Texture.TextureWrap v) Construct a new PostProcessor with the given parameters and the specified texture wrap mode -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEffect
(PostProcessorEffect effect) Adds the specified effect to the effect chain and transfer ownership to the PostProcessor, it will manage cleaning it up for you.int
int
buildEnabledEffectsList
(boolean cubemap, boolean reprojection) int
int
boolean
capture()
boolean
capture
(IntSupplier supplier) Starts capturing the scene, clears the buffer with the clear color specified bysetClearColor(Color)
orsetClearColor(float r, float g, float b, float a)
.boolean
captured()
After a capture/captureEnd action, returns the just captured bufferStops capturing the scene and returns the result, or null if nothing was captured.boolean
boolean
captureNoClear
(IntSupplier supplier) Starts capturing the scene ascapture()
, but without clearing the screen.boolean
boolean
boolean
void
dispose()
Frees owned resources.void
dispose
(boolean cleanAllBuffers) int
Returns the number of the currently enabled effectsstatic com.badlogic.gdx.graphics.Pixmap.Format
Returns the internal framebuffer format, computed from the parameters specified during construction.com.badlogic.gdx.math.Rectangle
boolean
Whether the post-processor is enabledboolean
isReady()
If called before capturing it will indicate if the next capture call will succeed or not.static boolean
isStateEnabled
(int pname) Provides a way to query the pipeline for the most used statesstatic PingPongBuffer
newPingPongBuffer
(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean hasDepth) Creates and returns a managed PingPongBuffer buffer, just create and forget.static PingPongBuffer
newPingPongBuffer
(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format pixmapFormat, boolean hasDepth, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Creates and returns a managed PingPongBuffer buffer, just create and forget.void
rebind()
Regenerates and/or rebinds owned resources when needed, eg.void
removeEffect
(PostProcessorEffect effect) Removes the specified effect from the effect chain.void
render()
Convenience method to render to screen.void
render
(com.badlogic.gdx.graphics.glutils.FrameBuffer dest) Stops capturing the scene and apply the effect chain, if there is one.void
setBufferTextureFilter
(com.badlogic.gdx.graphics.Texture.TextureFilter minFilter, com.badlogic.gdx.graphics.Texture.TextureFilter magFilter) void
setBufferTextureWrap
(com.badlogic.gdx.graphics.Texture.TextureWrap u, com.badlogic.gdx.graphics.Texture.TextureWrap v) void
setClearBits
(int bits) Sets the clear bit for when glClear is invoked.void
setClearColor
(float r, float g, float b, float a) Sets the color that will be used to clear the buffer.void
setClearColor
(com.badlogic.gdx.graphics.Color color) Sets the color that will be used to clear the buffer.void
setClearDepth
(float depth) Sets the depth value with which to clear the depth buffer when needed.void
setEnabled
(boolean enabled) Sets whether the post-processor should be enabledvoid
setListener
(PostProcessorListener listener) Sets the listener that will receive events triggered by the PostProcessor rendering pipeline.void
setViewport
(com.badlogic.gdx.math.Rectangle viewport) Sets the viewport to be restored, if null is specified then the viewport will NOT be restored at all.
-
Field Details
-
EnableQueryStates
public static boolean EnableQueryStatesEnable pipeline state queries: beware the pipeline can stall! -
currentPostProcessor
-
-
Constructor Details
-
PostProcessor
public PostProcessor(IPostProcessor.RenderType rt, boolean useDepth, boolean useAlphaChannel, boolean use32Bits) Construct a new PostProcessor with FBO dimensions set to the size of the screen -
PostProcessor
public PostProcessor(IPostProcessor.RenderType rt, int fboWidth, int fboHeight, boolean hasDepth, boolean useAlphaChannel, boolean use32Bits, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Construct a new PostProcessor with the given parameters, defaulting to TextureWrap.ClampToEdge as texture wrap mode -
PostProcessor
public PostProcessor(IPostProcessor.RenderType rt, int fboWidth, int fboHeight, boolean useDepth, boolean useAlphaChannel, boolean use32Bits, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer, com.badlogic.gdx.graphics.Texture.TextureWrap u, com.badlogic.gdx.graphics.Texture.TextureWrap v) Construct a new PostProcessor with the given parameters and the specified texture wrap mode
-
-
Method Details
-
newPingPongBuffer
public static PingPongBuffer newPingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean hasDepth) Creates and returns a managed PingPongBuffer buffer, just create and forget. If rebind() is called on context loss, managed PingPongBuffers will be rebound for you.This is a drop-in replacement for the same-signature PingPongBuffer's constructor.
-
newPingPongBuffer
public static PingPongBuffer newPingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format pixmapFormat, boolean hasDepth, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Creates and returns a managed PingPongBuffer buffer, just create and forget. If rebind() is called on context loss, managed PingPongBuffers will be rebound for you.This is a drop-in replacement for the same-signature PingPongBuffer's constructor.
-
isStateEnabled
public static boolean isStateEnabled(int pname) Provides a way to query the pipeline for the most used states -
getFramebufferFormat
public static com.badlogic.gdx.graphics.Pixmap.Format getFramebufferFormat()Returns the internal framebuffer format, computed from the parameters specified during construction. NOTE: the returned Format will be valid after construction and NOT early! -
getViewport
public com.badlogic.gdx.math.Rectangle getViewport() -
setViewport
public void setViewport(com.badlogic.gdx.math.Rectangle viewport) Sets the viewport to be restored, if null is specified then the viewport will NOT be restored at all.The predefined effects will restore the viewport settings at the final blitting stage (render to screen) by invoking the restoreViewport static method.
-
dispose
public void dispose()Frees owned resources.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
dispose
public void dispose(boolean cleanAllBuffers) -
isEnabled
public boolean isEnabled()Whether the post-processor is enabled -
setEnabled
public void setEnabled(boolean enabled) Sets whether the post-processor should be enabled -
isReady
public boolean isReady()If called before capturing it will indicate if the next capture call will succeed or not. -
getEnabledEffectsCount
public int getEnabledEffectsCount()Returns the number of the currently enabled effects -
setListener
Sets the listener that will receive events triggered by the PostProcessor rendering pipeline. -
addEffect
Adds the specified effect to the effect chain and transfer ownership to the PostProcessor, it will manage cleaning it up for you. The order of the inserted effects IS important, since effects will be applied in a FIFO fashion, the first added is the first being applied. -
removeEffect
Removes the specified effect from the effect chain. -
setClearColor
public void setClearColor(com.badlogic.gdx.graphics.Color color) Sets the color that will be used to clear the buffer. -
setClearColor
public void setClearColor(float r, float g, float b, float a) Sets the color that will be used to clear the buffer. -
setClearBits
public void setClearBits(int bits) Sets the clear bit for when glClear is invoked. -
setClearDepth
public void setClearDepth(float depth) Sets the depth value with which to clear the depth buffer when needed. -
setBufferTextureFilter
public void setBufferTextureFilter(com.badlogic.gdx.graphics.Texture.TextureFilter minFilter, com.badlogic.gdx.graphics.Texture.TextureFilter magFilter) -
setBufferTextureWrap
public void setBufferTextureWrap(com.badlogic.gdx.graphics.Texture.TextureWrap u, com.badlogic.gdx.graphics.Texture.TextureWrap v) -
capture
public boolean capture() -
captureCubemap
public boolean captureCubemap() -
captureVR
public boolean captureVR() -
capture
Starts capturing the scene, clears the buffer with the clear color specified bysetClearColor(Color)
orsetClearColor(float r, float g, float b, float a)
.- Returns:
- true or false, whether capturing has been initiated. Capturing will fail in case there are no enabled effects in the chain or this instance is not enabled or capturing is already started.
-
captureNoClear
public boolean captureNoClear() -
captureNoClearCubemap
public boolean captureNoClearCubemap() -
captureNoClearReprojection
public boolean captureNoClearReprojection() -
captureNoClear
Starts capturing the scene ascapture()
, but without clearing the screen.- Returns:
- true or false, whether or not capturing has been initiated.
-
captureEnd
Stops capturing the scene and returns the result, or null if nothing was captured. -
getCombinedBuffer
-
captured
After a capture/captureEnd action, returns the just captured buffer -
rebind
public void rebind()Regenerates and/or rebinds owned resources when needed, eg. when the OpenGL context is lost. -
render
public void render(com.badlogic.gdx.graphics.glutils.FrameBuffer dest) Stops capturing the scene and apply the effect chain, if there is one. If the specified output FrameBuffer is NULL, then the rendering will be performed to screen. -
render
public void render()Convenience method to render to screen. -
buildEnabledEffectsList
public int buildEnabledEffectsList(boolean cubemap, boolean reprojection) -
buildEnabledEffectsList
public int buildEnabledEffectsList() -
buildEnabledEffectsListCubemap
public int buildEnabledEffectsListCubemap() -
buildEnabledEffectsListVR
public int buildEnabledEffectsListVR()
-