Class PingPongBuffer

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

public final class PingPongBuffer extends Object implements com.badlogic.gdx.utils.Disposable
  • Field Details Link icon

    • ownResources Link icon

      public final boolean ownResources
    • texture1 Link icon

      public com.badlogic.gdx.graphics.Texture texture1
    • texture2 Link icon

      public com.badlogic.gdx.graphics.Texture texture2
    • textureDepth Link icon

      public com.badlogic.gdx.graphics.Texture textureDepth
    • textureVel Link icon

      public com.badlogic.gdx.graphics.Texture textureVel
    • textureNormal Link icon

      public com.badlogic.gdx.graphics.Texture textureNormal
    • textureReflectionMap Link icon

      public com.badlogic.gdx.graphics.Texture textureReflectionMap
    • width Link icon

      public int width
    • height Link icon

      public int height
  • Constructor Details Link icon

    • PingPongBuffer Link icon

      public PingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format pixmapFormat, boolean hasDepth, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer)
      Creates a new ping-pong buffer and owns the resources.
    • PingPongBuffer Link icon

      public PingPongBuffer(GaiaSkyFrameBuffer buffer1, GaiaSkyFrameBuffer buffer2)
      Creates a new ping-pong buffer with the given buffers.
  • Method Details Link icon

    • createMainFrameBuffer Link icon

      public static GaiaSkyFrameBuffer createMainFrameBuffer(int width, int height, boolean hasDepth, boolean hasVelocity, boolean hasNormal, boolean hasReflectionMask, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean preventFloatBuffer)
    • set Link icon

      public void set(GaiaSkyFrameBuffer buffer1, GaiaSkyFrameBuffer buffer2)
      An instance of this object can also be used to manipulate some other externally-allocated buffers, applying just the same ping-ponging behavior.

      If this instance of the object was owning the resources, they will be preserved and will be restored by a reset() call.

      Parameters:
      buffer1 - the first buffer
      buffer2 - the second buffer
    • reset Link icon

      public void reset()
      Restore the previous buffers if the instance was owning resources.
    • dispose Link icon

      public void dispose()
      Free the resources, if any.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • rebind Link icon

      public void rebind()
      When needed graphics memory could be invalidated so buffers should be rebuilt.
    • begin Link icon

      public void begin()
      Ensures the initial buffer state is always the same before starting ping-ponging.
    • capture Link icon

      public com.badlogic.gdx.graphics.Texture capture()
      Starts and/or continue ping-ponging, begin capturing on the next available buffer, returns the result of the previous call.
      Returns:
      the Texture containing the result.
    • end Link icon

      public void end()
      Finishes ping-ponging, must always be called after a call to capture()
    • getSouceTexture Link icon

      public com.badlogic.gdx.graphics.Texture getSouceTexture()
      Returns:
      the source texture of the current ping-pong chain.
    • getSourceBuffer Link icon

      public GaiaSkyFrameBuffer getSourceBuffer()
      Returns:
      the source buffer of the current ping-pong chain.
    • getResultTexture Link icon

      public com.badlogic.gdx.graphics.Texture getResultTexture()
      Returns:
      the result's texture of the latest capture().
    • getResultBuffer Link icon

      public GaiaSkyFrameBuffer getResultBuffer()
      Returns:
      Returns the result's buffer of the latest capture().
    • getMainBuffer Link icon

      public GaiaSkyFrameBuffer getMainBuffer()
    • getDepthTexture Link icon

      public com.badlogic.gdx.graphics.Texture getDepthTexture()
      Returns:
      the depth texture attachment containing the depth buffer