public final class PingPongBuffer extends Object
Upon begin()
the buffer is reset to a known initial state, this is usually done just
before the first usage of the buffer.
Subsequent capture()
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
#getSourceTexture()
, getSourceBuffer()
, getResultTexture()
or
getResultBuffer()
.
When finished, end()
should be called to stop capturing. When the OpenGL context is
lost, rebind()
should be called.
Modifier and Type | Field and Description |
---|---|
com.badlogic.gdx.graphics.glutils.FrameBuffer |
buffer1 |
com.badlogic.gdx.graphics.glutils.FrameBuffer |
buffer2 |
int |
height |
boolean |
ownResources |
com.badlogic.gdx.graphics.Texture |
texture1 |
com.badlogic.gdx.graphics.Texture |
texture2 |
int |
width |
Constructor and Description |
---|
PingPongBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer buffer1,
com.badlogic.gdx.graphics.glutils.FrameBuffer buffer2)
Creates a new ping-pong buffer with the given buffers.
|
PingPongBuffer(int width,
int height,
com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat,
boolean hasDepth)
Creates a new ping-pong buffer and owns the resources.
|
Modifier and Type | Method and Description |
---|---|
void |
begin()
Ensures the initial buffer state is always the same before starting ping-ponging.
|
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
capture() call. |
void |
dispose()
Free the resources, if any.
|
void |
end()
Finishes ping-ponging, must always be called after a call to
capture() |
com.badlogic.gdx.graphics.glutils.FrameBuffer |
getResultBuffer() |
com.badlogic.gdx.graphics.Texture |
getResultTexture() |
com.badlogic.gdx.graphics.Texture |
getSouceTexture() |
com.badlogic.gdx.graphics.glutils.FrameBuffer |
getSourceBuffer() |
void |
rebind()
When needed graphics memory could be invalidated so buffers should be rebuilt.
|
void |
reset()
Restore the previous buffers if the instance was owning resources.
|
void |
set(com.badlogic.gdx.graphics.glutils.FrameBuffer buffer1,
com.badlogic.gdx.graphics.glutils.FrameBuffer buffer2)
An instance of this object can also be used to manipulate some other externally-allocated
buffers, applying just the same ping-ponging behavior.
|
public final boolean ownResources
public com.badlogic.gdx.graphics.glutils.FrameBuffer buffer1
public com.badlogic.gdx.graphics.glutils.FrameBuffer buffer2
public com.badlogic.gdx.graphics.Texture texture1
public com.badlogic.gdx.graphics.Texture texture2
public int width
public int height
public PingPongBuffer(int width, int height, com.badlogic.gdx.graphics.Pixmap.Format frameBufferFormat, boolean hasDepth)
public PingPongBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer buffer1, com.badlogic.gdx.graphics.glutils.FrameBuffer buffer2)
public void set(com.badlogic.gdx.graphics.glutils.FrameBuffer buffer1, com.badlogic.gdx.graphics.glutils.FrameBuffer buffer2)
If this instance of the object was owning the resources, they will be preserved and will be
restored by a reset()
call.
buffer1
- the first bufferbuffer2
- the second bufferpublic void reset()
public void dispose()
public void rebind()
public void begin()
public com.badlogic.gdx.graphics.Texture capture()
capture()
call.public void end()
capture()
public com.badlogic.gdx.graphics.Texture getSouceTexture()
public com.badlogic.gdx.graphics.glutils.FrameBuffer getSourceBuffer()
public com.badlogic.gdx.graphics.Texture getResultTexture()
capture()
.public com.badlogic.gdx.graphics.glutils.FrameBuffer getResultBuffer()
capture()
.Copyright © 2020. All rights reserved.