Package arc.fx.util
Class PingPongBuffer
java.lang.Object
arc.fx.util.PingPongBuffer
Encapsulates a framebuffer with the ability to ping-pong between two buffers.
Upon begin()
the buffer is reset to a known initial state, this is usually done just before the first usage of the
buffer.
Subsequent swap()
calls will initiate writing to the next available buffer, returning the previously used one,
effectively ping-ponging between the two. Until end()
is called, chained rendering will be possible by retrieving the
necessary buffers via getSrcTexture()
, getSrcBuffer()
, getDstTexture()
or
getDstBuffer()
.
When finished, end()
should be called to stop capturing. When the OpenGL context is lost, rebind()
should be
called.
-
Constructor Summary
ConstructorDescriptionPingPongBuffer
(Pixmap.Format fbFormat) Initializes ping-pong buffer with the size of the client's area (usually window size).PingPongBuffer
(Pixmap.Format fbFormat, int width, int height) PingPongBuffer
(Pixmap.Format fbFormat, int width, int height, boolean depth, boolean stencil) Initializes ping-pong buffer with the given size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin()
Start capturing into the destination buffer.void
clear
(float r, float g, float b, float a) Cleans up managed buffers with specified color.void
Cleans up managed buffers with specified color.void
dispose()
void
end()
Finishes ping-ponging.void
rebind()
Restores buffer OpenGL parameters.void
resize
(int width, int height) void
setTextureParams
(Texture.TextureWrap u, Texture.TextureWrap v, Texture.TextureFilter min, Texture.TextureFilter mag) void
swap()
Swaps source/target buffers.
-
Constructor Details
-
PingPongBuffer
Initializes ping-pong buffer with the size of the client's area (usually window size). If you use different OpenGL viewport, better usePingPongBuffer(Format, int, int)
and specify the size manually.- Parameters:
fbFormat
- Pixel format of buffer.
-
PingPongBuffer
-
PingPongBuffer
public PingPongBuffer(Pixmap.Format fbFormat, int width, int height, boolean depth, boolean stencil) Initializes ping-pong buffer with the given size.- Parameters:
fbFormat
- Pixel format of buffer.
-
-
Method Details
-
dispose
public void dispose() -
resize
public void resize(int width, int height) -
rebind
public void rebind()Restores buffer OpenGL parameters. Could be useful in case of OpenGL context loss. -
begin
public void begin() -
swap
public void swap()Swaps source/target buffers. May be called outside of capturing state. -
end
public void end()Finishes ping-ponging. Must be called afterbegin()
. -
getSrcTexture
- Returns:
- the source texture of the current ping-pong chain.
-
getSrcBuffer
- Returns:
- the source buffer of the current ping-pong chain.
-
getDstTexture
- Returns:
- the result's texture of the latest
swap()
.
-
getDstBuffer
- Returns:
- Returns the result's buffer of the latest
swap()
.
-
setTextureParams
public void setTextureParams(Texture.TextureWrap u, Texture.TextureWrap v, Texture.TextureFilter min, Texture.TextureFilter mag) -
clear
Cleans up managed buffers with specified color. -
clear
public void clear(float r, float g, float b, float a) Cleans up managed buffers with specified color.
-