APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics.glutils

public Class FrameBuffer

extends GLFrameBuffer<Texture>
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.graphics.glutils.FloatFrameBuffer
Imports
com.badlogic.gdx.Application, .Gdx, com.badlogic.gdx.graphics.GL20, .Pixmap, .Texture, .Texture.TextureFilter, .Texture.TextureWrap

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 texture for the color attachment and a renderbuffer for the depth buffer. You can get a hold of the texture by FrameBuffer#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

Author
mzechner, realitix

Field Summary

Inherited from com.badlogic.gdx.graphics.glutils.GLFrameBuffer:
bufferBuilderbufferscolorBufferHandlesdefaultFramebufferHandledefaultFramebufferHandleInitializeddepthbufferHandledepthStencilPackedBufferHandleframebufferHandleGL_DEPTH24_STENCIL8_OEShasDepthStencilPackedBufferisMRTstencilbufferHandletextureAttachments

Constructor Summary

AccessConstructor and Description
pack-priv
protected
FrameBuffer(GLFrameBuffer.GLFrameBufferBuilder<? extends GLFrameBuffer<Texture>> bufferBuilder)

Creates a GLFrameBuffer from the specifications provided by bufferBuilder

public
FrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth)

Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.

public
FrameBuffer(Pixmap.Format
the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are color-renderable
format
,
int
the width of the framebuffer in pixels
width
,
int
the height of the framebuffer in pixels
height
,
boolean
whether to attach a depth buffer
hasDepth
,
boolean hasStencil)

Creates a new FrameBuffer having the given dimensions and potentially a depth and a stencil buffer attached.

Method Summary

Modifier and TypeMethod and Description
protected void
attachFrameBufferColorTexture(Texture texture)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.attachFrameBufferColorTexture.

Override this method in a derived class to attach the backing texture to the GL framebuffer object.

protected Texture
createTexture(GLFrameBuffer.FrameBufferTextureAttachmentSpec attachmentSpec)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.createTexture.

Override this method in a derived class to set up the backing texture as you like.

protected void
disposeColorTexture(Texture colorTexture)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.disposeColorTexture.

Override this method in a derived class to dispose the backing texture as you like.

public static void
Inherited from com.badlogic.gdx.graphics.glutils.GLFrameBuffer:
beginbindbuildclearAllFrameBuffersdisposeendendgetColorBufferHandlegetColorBufferTexturegetDepthBufferHandlegetDepthStencilPackedBuffergetFramebufferHandlegetHeightgetManagedStatusgetManagedStatusgetStencilBufferHandlegetTextureAttachmentsgetWidthinvalidateAllFrameBufferssetFrameBufferViewporttransfertransfer

Constructor Detail

FrameBufferback to summary
pack-priv FrameBuffer()
FrameBufferback to summary
protected FrameBuffer(GLFrameBuffer.GLFrameBufferBuilder<? extends GLFrameBuffer<Texture>> bufferBuilder)

Creates a GLFrameBuffer from the specifications provided by bufferBuilder

FrameBufferback to summary
public FrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth)

Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.

FrameBufferback to summary
public FrameBuffer(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.

Parameters
format:Pixmap.Format

the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are color-renderable

width:int

the width of the framebuffer in pixels

height:int

the height of the framebuffer in pixels

hasDepth:boolean

whether to attach a depth buffer

Exceptions
GdxRuntimeException:
in case the FrameBuffer could not be created

Method Detail

attachFrameBufferColorTextureback to summary
protected void attachFrameBufferColorTexture(Texture texture)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.attachFrameBufferColorTexture.

Doc from com.badlogic.gdx.graphics.glutils.GLFrameBuffer.attachFrameBufferColorTexture.

Override this method in a derived class to attach the backing texture to the GL framebuffer object.

Annotations
@Override
createTextureback to summary
protected Texture createTexture(GLFrameBuffer.FrameBufferTextureAttachmentSpec attachmentSpec)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.createTexture.

Doc from com.badlogic.gdx.graphics.glutils.GLFrameBuffer.createTexture.

Override this method in a derived class to set up the backing texture as you like.

Annotations
@Override
disposeColorTextureback to summary
protected void disposeColorTexture(Texture colorTexture)

Implements abstract com.badlogic.gdx.graphics.glutils.GLFrameBuffer.disposeColorTexture.

Doc from com.badlogic.gdx.graphics.glutils.GLFrameBuffer.disposeColorTexture.

Override this method in a derived class to dispose the backing texture as you like.

Annotations
@Override
unbindback to summary
public static void unbind()

Hides com.badlogic.gdx.graphics.glutils.GLFrameBuffer.unbind.

See GLFrameBuffer#unbind()