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 FrameBufferCubemap#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();
| Modifier and Type | Field and Description |
|---|---|
| private static final Cubemap. | cubemapSides
cubemap sides cache |
| private int | currentSide
the zero-based index of the active side |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| protected | FrameBufferCubemap(GLFrameBuffer.
Creates a GLFrameBuffer from the specifications provided by bufferBuilder |
| public | FrameBufferCubemap(Pixmap.
Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. |
| public | FrameBufferCubemap(Pixmap.
the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are
color-renderable format,the width of the cubemap in pixels width, int the height of the cubemap in pixels height, boolean whether to attach a depth buffer hasDepth, boolean whether to attach a stencil buffer 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(Cubemap texture)
Implements abstract com. Override this method in a derived class to attach the backing texture to the GL framebuffer object. |
| public void | bind()
Overrides com. Makes the frame buffer current so everything gets drawn to it, must be followed by call to either |
| protected void | bindSide(final Cubemap.
The side to bind sideBind the side, making it active to render on. |
| protected Cubemap | createTexture(GLFrameBuffer.
Implements abstract com. Override this method in a derived class to set up the backing texture as you like. |
| protected void | disposeColorTexture(Cubemap colorTexture)
Implements abstract com. Override this method in a derived class to dispose the backing texture as you like. |
| public Cubemap. | |
| public boolean |
| cubemapSides | back to summary |
|---|---|
| private static final Cubemap. cubemap sides cache | |
| currentSide | back to summary |
|---|---|
| private int currentSide the zero-based index of the active side | |
| FrameBufferCubemap | back to summary |
|---|---|
| pack-priv FrameBufferCubemap() | |
| FrameBufferCubemap | back to summary |
|---|---|
| protected FrameBufferCubemap(GLFrameBuffer. Creates a GLFrameBuffer from the specifications provided by bufferBuilder | |
| FrameBufferCubemap | back to summary |
|---|---|
| public FrameBufferCubemap(Pixmap. Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. | |
| FrameBufferCubemap | back to summary |
|---|---|
| public FrameBufferCubemap(Pixmap. Creates a new FrameBuffer having the given dimensions and potentially a depth and a stencil buffer attached.
| |
| attachFrameBufferColorTexture | back to summary |
|---|---|
| protected void attachFrameBufferColorTexture(Cubemap texture) Implements abstract com. Doc from com. Override this method in a derived class to attach the backing texture to the GL framebuffer object.
| |
| bind | back to summary |
|---|---|
| public void bind() Overrides com. Makes the frame buffer current so everything gets drawn to it, must be followed by call to either
| |
| bindSide | back to summary |
|---|---|
| protected void bindSide(final Cubemap. Bind the side, making it active to render on. Should be called in between a call to
| |
| createTexture | back to summary |
|---|---|
| protected Cubemap createTexture(GLFrameBuffer. Implements abstract com. Doc from com. Override this method in a derived class to set up the backing texture as you like.
| |
| disposeColorTexture | back to summary |
|---|---|
| protected void disposeColorTexture(Cubemap colorTexture) Implements abstract com. Doc from com. Override this method in a derived class to dispose the backing texture as you like.
| |
| getSide | back to summary |
|---|---|
| public Cubemap. Get the currently bound side. | |
| nextSide | back to summary |
|---|---|
| public boolean nextSide() Bind the next side of cubemap and return false if no more side. Should be called in between a call to | |