Skip to content

FrameBuffer

final class FrameBuffer
Package: dev.joid.lib.render.framebuffer · Module: core · Source: FrameBuffer.java

An offscreen image that you draw into once and then draw as many times as you want.

Fill it with your own drawing, then draw it where you need it; it keeps its content until you fill it again (Draw once, reuse every frame).

A framebuffer holds GPU memory: create it on the render thread and call delete() when you are done with it.

ReturnsSignatureSummary
FrameBuffercreate(int width, int height, TextureFilter filter) factoryCreates a framebuffer of width × height screen pixels, drawn later with the filter filter.

ReturnsSignatureSummary
voiddelete()Frees the GPU memory of the framebuffer; do not use it afterwards.
thisfill(Runnable runnable) fluentRuns runnable into the framebuffer, with one unit per pixel and (0, 0) at its top-left corner.
thisfill(double x, double y, double width, double height, Runnable runnable) fluentRuns runnable into the framebuffer, with the area at x, y of width × height stretched over the whole framebuffer, so that you draw in the coordinates of that area.
thisdraw(double x, double y, double width, double height) fluentDraws the content at x, y, stretched to width × height, with premultiplied blending.
intgetWidth()Returns the width, in pixels.
intgetHeight()Returns the height, in pixels.
IFrameBuffergetHandle()Returns the framebuffer of the render bridge, for drawing it yourself with DrawResource.drawTexture.
TextureFiltergetFilter()Returns the filter used when the framebuffer is drawn.
booleanisFilled()If true, the framebuffer has been filled at least once and can be drawn.

FrameBuffer create(int width, int height, TextureFilter filter) factory

Creates a framebuffer of width × height screen pixels, drawn later with the filter filter. Its content is undefined until the first fill.

void delete()

Frees the GPU memory of the framebuffer; do not use it afterwards.

this fill(Runnable runnable) fluent

Runs runnable into the framebuffer, with one unit per pixel and (0, 0) at its top-left corner. It does not clear the framebuffer first: clear it in runnable when you redraw over an earlier content.

this fill(double x, double y, double width, double height, Runnable runnable) fluent

Runs runnable into the framebuffer, with the area at x, y of width × height stretched over the whole framebuffer, so that you draw in the coordinates of that area.

this draw(double x, double y, double width, double height) fluent

Throws:

  • IllegalStateException: The framebuffer of …x… is empty, call fill(…) before draw(…)

Draws the content at x, y, stretched to width × height, with premultiplied blending. Throws IllegalStateException before the first fill.

int getWidth()

Returns the width, in pixels.

int getHeight()

Returns the height, in pixels.

IFrameBuffer getHandle()

Returns the framebuffer of the render bridge, for drawing it yourself with DrawResource.drawTexture.

TextureFilter getFilter()

Returns the filter used when the framebuffer is drawn.

boolean isFilled()

If true, the framebuffer has been filled at least once and can be drawn.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page