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();
GLFrameBuffer.FloatFrameBufferBuilder, GLFrameBuffer.FrameBufferBuilder, GLFrameBuffer.FrameBufferCubemapBuilder, GLFrameBuffer.GLFrameBufferBuilder<U extends GLFrameBuffer<? extends GLTexture>>| 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 |
|---|---|
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. |
Cubemap.CubemapSide |
getSide()
Get the currently bound side.
|
boolean |
nextSide()
Bind the next side of cubemap and return false if no more side.
|
begin, clearAllFrameBuffers, dispose, end, end, getColorBufferTexture, getDepthBufferHandle, getFramebufferHandle, getHeight, getManagedStatus, getManagedStatus, getStencilBufferHandle, getTextureAttachments, getWidth, invalidateAllFrameBuffers, 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 createdpublic 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.public Cubemap.CubemapSide getSide()
Copyright © 2021. All rights reserved.