Class PostProcessor

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

public final class PostProcessor extends Object implements com.badlogic.gdx.utils.Disposable
  • 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 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 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 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.
    • addEffect

      public void addEffect(PostProcessorEffect effect, Class<? extends PostProcessorEffect> after)
      Adds the given effect after an effect with the given type. If no effect with the given type exists, it adds the effect at the end.
    • 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, depending on whether 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()
    • 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 destination)
      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()