Package arc.graphics.gl
Class FrameBuffer
- All Implemented Interfaces:
Disposable
- Direct Known Subclasses:
FloatFrameBuffer
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 GLFrameBuffer.getTexture()
. 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
-
Nested Class Summary
Nested classes/interfaces inherited from class arc.graphics.gl.GLFrameBuffer
GLFrameBuffer.FloatFrameBufferBuilder, GLFrameBuffer.FrameBufferBuilder, GLFrameBuffer.FrameBufferCubemapBuilder, GLFrameBuffer.FrameBufferRenderBufferAttachmentSpec, GLFrameBuffer.FrameBufferTextureAttachmentSpec, GLFrameBuffer.GLFrameBufferBuilder<U extends GLFrameBuffer<? extends GLTexture>>
-
Field Summary
Fields inherited from class arc.graphics.gl.GLFrameBuffer
bufferBuilder, bufferNesting, currentBoundFramebuffer, defaultFramebufferHandle, defaultFramebufferHandleInitialized, depthbufferHandle, depthStencilPackedBufferHandle, framebufferHandle, GL_DEPTH24_STENCIL8_OES, hasDepthStencilPackedBuffer, isMRT, lastBoundFramebuffer, stencilbufferHandle, textureAttachments
-
Constructor Summary
ModifierConstructorDescriptionCreates a new 2x2 buffer.FrameBuffer
(int width, int height) Creates a new FrameBuffer having the given dimensions in the format RGBA8888 and no depth buffer.FrameBuffer
(int width, int height, boolean hasDepth) Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.protected
FrameBuffer
(GLFrameBuffer.GLFrameBufferBuilder<? extends GLFrameBuffer<Texture>> bufferBuilder) Creates a GLFrameBuffer from the specifications provided by bufferBuilderFrameBuffer
(Pixmap.Format format, int width, int height) Creates a new FrameBuffer having the given dimensions and no depth buffer.FrameBuffer
(Pixmap.Format format, int width, int height, boolean hasDepth) Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
attachFrameBufferColorTexture
(Texture texture) Override this method in a derived class to attach the backing texture to the GL framebuffer object.void
Blits this buffer onto the screen using the specified shader.protected void
create
(Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) protected Texture
createTexture
(GLFrameBuffer.FrameBufferTextureAttachmentSpec attachmentSpec) Override this method in a derived class to set up the backing texture as you like.protected void
disposeColorTexture
(Texture colorTexture) Override this method in a derived class to dispose the backing texture as you like.void
resize
(int width, int height) Note that this does nothing if the width and height are the same.boolean
resizeCheck
(int width, int height) static void
unbind()
Methods inherited from class arc.graphics.gl.GLFrameBuffer
begin, begin, beginBind, bind, build, dispose, end, endBind, getBufferNesting, getDepthBufferHandle, getDepthStencilPackedBuffer, getFramebufferHandle, getHeight, getStencilBufferHandle, getTexture, getTextureAttachments, getWidth, isBound, setFrameBufferViewport
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface arc.util.Disposable
isDisposed
-
Constructor Details
-
FrameBuffer
protected FrameBuffer(GLFrameBuffer.GLFrameBufferBuilder<? extends GLFrameBuffer<Texture>> bufferBuilder) Creates a GLFrameBuffer from the specifications provided by bufferBuilder -
FrameBuffer
public FrameBuffer()Creates a new 2x2 buffer. Resize before use. -
FrameBuffer
public FrameBuffer(int width, int height) Creates a new FrameBuffer having the given dimensions in the format RGBA8888 and no depth buffer. -
FrameBuffer
Creates a new FrameBuffer having the given dimensions and no depth buffer. -
FrameBuffer
Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. -
FrameBuffer
public FrameBuffer(int width, int height, boolean hasDepth) Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. -
FrameBuffer
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
- 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 framebuffer in pixelsheight
- the height of the framebuffer in pixelshasDepth
- whether to attach a depth buffer- Throws:
ArcRuntimeException
- in case the FrameBuffer could not be created
-
-
Method Details
-
create
protected void create(Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) -
blit
Blits this buffer onto the screen using the specified shader. -
resizeCheck
public boolean resizeCheck(int width, int height) -
resize
public void resize(int width, int height) Note that this does nothing if the width and height are the same. -
unbind
public static void unbind() -
createTexture
Description copied from class:GLFrameBuffer
Override this method in a derived class to set up the backing texture as you like.- Specified by:
createTexture
in classGLFrameBuffer<Texture>
-
disposeColorTexture
Description copied from class:GLFrameBuffer
Override this method in a derived class to dispose the backing texture as you like.- Specified by:
disposeColorTexture
in classGLFrameBuffer<Texture>
-
attachFrameBufferColorTexture
Description copied from class:GLFrameBuffer
Override this method in a derived class to attach the backing texture to the GL framebuffer object.- Specified by:
attachFrameBufferColorTexture
in classGLFrameBuffer<Texture>
-