Class PostProcessor

java.lang.Object
gaiasky.util.gdx.contrib.postprocess.PostProcessor
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public final class PostProcessor extends Object implements com.badlogic.gdx.utils.Disposable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    static boolean
    Enable pipeline state queries: beware the pipeline can stall!
  • Constructor Summary

    Constructors
    Constructor
    Description
    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(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(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 Type
    Method
    Description
    void
    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
     
    boolean
    capture(IntSupplier supplier)
    Starts capturing the scene, clears the buffer with the clear color specified by setClearColor(Color) or setClearColor(float r, float g, float b, float a).
    boolean
     
    After a capture/captureEnd action, returns the just captured buffer
    Stops capturing the scene and returns the result, or null if nothing was captured.
    boolean
     
    boolean
    Starts capturing the scene as capture(), but without clearing the screen.
    boolean
     
    boolean
     
    boolean
     
    void
    Frees owned resources.
    void
    dispose(boolean cleanAllBuffers)
     
     
    int
    Returns the number of the currently enabled effects
    static 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 enabled
    boolean
    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 states
    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.
    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
    Regenerates and/or rebinds owned resources when needed, eg.
    void
    Removes the specified effect from the effect chain.
    void
    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 enabled
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EnableQueryStates

      public static boolean EnableQueryStates
      Enable pipeline state queries: beware the pipeline can stall!
    • currentPostProcessor

      public static PostProcessor 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 interface com.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

      public void setListener(PostProcessorListener listener)
      Sets the listener that will receive events triggered by the PostProcessor rendering pipeline.
    • addEffect

      public void 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. 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

      public void removeEffect(PostProcessorEffect effect)
      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

      public boolean capture(IntSupplier supplier)
      Starts capturing the scene, clears the buffer with the clear color specified by setClearColor(Color) or setClearColor(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

      public boolean captureNoClear(IntSupplier supplier)
      Starts capturing the scene as capture(), but without clearing the screen.
      Returns:
      true or false, whether or not capturing has been initiated.
    • captureEnd

      public GaiaSkyFrameBuffer captureEnd()
      Stops capturing the scene and returns the result, or null if nothing was captured.
    • getCombinedBuffer

      public PingPongBuffer getCombinedBuffer()
    • captured

      public GaiaSkyFrameBuffer 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()