Class FramebufferPool
java.lang.Object
lol.trq.helios.fbo.FramebufferPool
- All Implemented Interfaces:
AutoCloseable
Reuses offscreen framebuffers across frames.
Screen-relative sizes come from SurfaceSize, in framebuffer pixels, so effects stay sharp on high-DPI
screens. When the surface size changes, every idle buffer is deleted, and buffers lent out under the old size are
deleted when they come back. Use it on the GL thread only.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquire(int width, int height, boolean depthStencil) Borrows a framebuffer of a fixed size.acquireScreen(int divisor, boolean depthStencil) Borrows a framebuffer the size of the window, or a fraction of it.voidclose()Deletes every idle framebuffer and retires the lent ones, as after a resize.intReturns how many framebuffers this pool has created in total.intReturns how many framebuffers sit idle.intReturns how many framebuffers are lent out.voidrelease(Framebuffer fb) Gives a framebuffer back.voidtrim()Deletes every idle framebuffer.
-
Constructor Details
-
FramebufferPool
Creates a pool.- Parameters:
gl- the backendsurface- the window framebuffer size
-
-
Method Details
-
acquireScreen
Borrows a framebuffer the size of the window, or a fraction of it.- Parameters:
divisor- 1 for full size, 2 for half, and so ondepthStencil- whether a depth-stencil buffer is needed- Returns:
- the framebuffer; give it back with
release(Framebuffer)
-
acquire
Borrows a framebuffer of a fixed size.- Parameters:
width- width in pixelsheight- height in pixelsdepthStencil- whether a depth-stencil buffer is needed- Returns:
- the framebuffer; give it back with
release(Framebuffer)
-
release
Gives a framebuffer back.- Parameters:
fb- a framebuffer from this pool- Throws:
IllegalArgumentException- if it is not currently lent out by this pool
-
idleCount
public int idleCount()Returns how many framebuffers sit idle.- Returns:
- the idle count
-
lentCount
public int lentCount()Returns how many framebuffers are lent out.- Returns:
- the lent count
-
createdCount
public int createdCount()Returns how many framebuffers this pool has created in total.- Returns:
- the creation count
-
trim
public void trim()Deletes every idle framebuffer. Lent ones are deleted when released. -
close
public void close()Deletes every idle framebuffer and retires the lent ones, as after a resize.- Specified by:
closein interfaceAutoCloseable
-