public class FrameBufferCubemap extends GLFrameBuffer<Cubemap>
Encapsulates OpenGL ES 2.0 frame buffer objects. This is a simple helper class which should cover most FBO uses. It will
automatically create a cubemap for the color attachment and a renderbuffer for the depth buffer. You can get a hold of the
cubemap by GLFrameBuffer.getColorBufferTexture(). This class will only work with OpenGL ES 2.0.
FrameBuffers are managed. In case of an OpenGL context loss, which only happens on Android when a user switches to another application or receives an incoming call, the framebuffer will be automatically recreated.
A FrameBuffer must be disposed if it is no longer needed
Typical use:
FrameBufferCubemap frameBuffer = new FrameBufferCubemap(Format.RGBA8888, fSize, fSize, true);
frameBuffer.begin();
while( frameBuffer.nextSide() ) {
frameBuffer.getSide().getUp(camera.up);
frameBuffer.getSide().getDirection(camera.direction);
camera.update();
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(camera);
modelBatch.render(renderableProviders);
modelBatch.end();
}
frameBuffer.end();
Cubemap cubemap = frameBuffer.getColorBufferCubemap();
buffers, colorTexture, defaultFramebufferHandle, defaultFramebufferHandleInitialized, depthbufferHandle, depthStencilPackedBufferHandle, format, framebufferHandle, GL_DEPTH24_STENCIL8_OES, hasDepth, hasDepthStencilPackedBuffer, hasStencil, height, stencilbufferHandle, width| Constructor and Description |
|---|
FrameBufferCubemap(Pixmap.Format format,
int width,
int height,
boolean hasDepth)
Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.
|
FrameBufferCubemap(Pixmap.Format format,
int width,
int height,
boolean hasDepth,
boolean hasStencil)
Creates a new FrameBuffer having the given dimensions and potentially a depth and a stencil buffer attached.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
attachFrameBufferColorTexture()
Override this method in a derived class to attach the backing texture to the GL framebuffer object.
|
void |
bind()
Makes the frame buffer current so everything gets drawn to it, must be followed by call to either
nextSide() or
bindSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide) to activate the side to render onto. |
protected void |
bindSide(Cubemap.CubemapSide side)
Bind the side, making it active to render on.
|
protected Cubemap |
createColorTexture()
Override this method in a derived class to set up the backing texture as you like.
|
protected void |
disposeColorTexture(Cubemap colorTexture)
Override this method in a derived class to dispose the backing texture as you like.
|
Cubemap.CubemapSide |
getSide()
Get the currently bound side.
|
boolean |
nextSide()
Bind the next side of cubemap and return false if no more side.
|
begin, build, clearAllFrameBuffers, dispose, end, end, getColorBufferTexture, getDepth, getDepthBufferHandle, getDepthStencilPackedBuffer, getFramebufferHandle, getHeight, getManagedStatus, getManagedStatus, getStencilBufferHandle, getWidth, invalidateAllFrameBuffers, setFrameBufferViewport, unbindpublic FrameBufferCubemap(Pixmap.Format format, int width, int height, boolean hasDepth)
format - width - height - hasDepth - public FrameBufferCubemap(Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil)
format - the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are
color-renderablewidth - the width of the cubemap in pixelsheight - the height of the cubemap in pixelshasDepth - whether to attach a depth bufferhasStencil - whether to attach a stencil bufferGdxRuntimeException - in case the FrameBuffer could not be createdprotected Cubemap createColorTexture()
GLFrameBuffercreateColorTexture in class GLFrameBuffer<Cubemap>protected void disposeColorTexture(Cubemap colorTexture)
GLFrameBufferdisposeColorTexture in class GLFrameBuffer<Cubemap>protected void attachFrameBufferColorTexture()
GLFrameBufferattachFrameBufferColorTexture in class GLFrameBuffer<Cubemap>public void bind()
nextSide() or
bindSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide) to activate the side to render onto.bind in class GLFrameBuffer<Cubemap>public boolean nextSide()
GLFrameBuffer.begin() and
#end to cycle to each side of the cubemap to render on.protected void bindSide(Cubemap.CubemapSide side)
GLFrameBuffer.begin() and GLFrameBuffer.end().side - The side to bindpublic Cubemap.CubemapSide getSide()