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.
Description
Section titled “Description”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.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
FrameBuffer | create(int width, int height, TextureFilter filter) factory | Creates a framebuffer of width × height screen pixels, drawn later with the filter filter. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
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. |
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 | Draws the content at x, y, stretched to width × height, with premultiplied blending. |
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. |
Creation details
Section titled “Creation details”create
Section titled “create”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.
Method details
Section titled “Method details”delete
Section titled “delete”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.
getWidth
Section titled “getWidth”int getWidth()
Returns the width, in pixels.
getHeight
Section titled “getHeight”int getHeight()
Returns the height, in pixels.
getHandle
Section titled “getHandle”IFrameBuffer getHandle()
Returns the framebuffer of the render bridge, for drawing it yourself with DrawResource.drawTexture.
getFilter
Section titled “getFilter”TextureFilter getFilter()
Returns the filter used when the framebuffer is drawn.
isFilled
Section titled “isFilled”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
