Class PingPongBuffer
java.lang.Object
gaiasky.render.postprocess.util.PingPongBuffer
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
-
Field Summary
FieldsModifier and TypeFieldDescriptionintfinal booleancom.badlogic.gdx.graphics.Texturecom.badlogic.gdx.graphics.Textureint -
Constructor Summary
ConstructorsConstructorDescriptionPingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format pixmapFormat, boolean hasDepth, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Creates a new ping-pong buffer and owns the resources. -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Ensures the initial buffer state is always the same before starting ping-ponging.com.badlogic.gdx.graphics.Texturecapture()Starts and/or continue ping-ponging, begin capturing on the next available buffer, returns the result of the previous call.static GaiaSkyFrameBuffercreateMainFrameBuffer(int width, int height, boolean hasDepth, boolean hasNormal, boolean hasReflectionMask, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean preventFloatBuffer) voiddispose()Free the resources, if any.voidend()Finishes ping-ponging, must always be called after a call tocapture()com.badlogic.gdx.graphics.Texturecom.badlogic.gdx.graphics.Texturevoidrebind()When needed graphics memory could be invalidated so buffers should be rebuilt.voidreset()Restore the previous buffers if the instance was owning resources.voidset(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.
-
Field Details
-
ownResources
public final boolean ownResources -
texture1
public com.badlogic.gdx.graphics.Texture texture1 -
texture2
public com.badlogic.gdx.graphics.Texture texture2 -
width
public int width -
height
public int height
-
-
Constructor Details
-
PingPongBuffer
public PingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format pixmapFormat, boolean hasDepth, boolean hasNormal, boolean hasReflectionMask, boolean preventFloatBuffer) Creates a new ping-pong buffer and owns the resources.
-
-
Method Details
-
createMainFrameBuffer
public static GaiaSkyFrameBuffer createMainFrameBuffer(int width, int height, boolean hasDepth, boolean hasNormal, boolean hasReflectionMask, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean preventFloatBuffer) -
set
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 bufferbuffer2- the second buffer
-
reset
public void reset()Restore the previous buffers if the instance was owning resources. -
dispose
public void dispose()Free the resources, if any.- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable
-
rebind
public void rebind()When needed graphics memory could be invalidated so buffers should be rebuilt. -
begin
public void begin()Ensures the initial buffer state is always the same before starting ping-ponging. -
capture
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
public void end()Finishes ping-ponging, must always be called after a call tocapture() -
getSouceTexture
public com.badlogic.gdx.graphics.Texture getSouceTexture()- Returns:
- the source texture of the current ping-pong chain.
-
getSourceBuffer
- Returns:
- the source buffer of the current ping-pong chain.
-
getResultTexture
public com.badlogic.gdx.graphics.Texture getResultTexture()- Returns:
- the result's texture of the latest
capture().
-
getResultBuffer
- Returns:
- Returns the result's buffer of the latest
capture().
-
getMainBuffer
-