IRenderBridge
interface IRenderBridge
Extends: IBridge
Known subtypes: RenderBridge
Package: dev.joid.lib.bridge.render · Module: core · Source: IRenderBridge.java
The bridge that draws every pixel of JOID: it clears targets, draws triangles and lines, and creates textures, framebuffers and shaders.
Description
Section titled “Description”The core reads it from BridgeHandler.RENDER; DrawUtils goes through it.
A backend extends RenderBridge, which implements the state, the matrices and the frame and leaves the GPU calls to write.
Every method runs on the render thread.
Let the host draw inside a frame reads it from a node to find the area of the node in screen pixels.
Learn more
Section titled “Learn more”- Render bridge
- Render pipeline
- Drawing resources and transforms
- Embedding JOID
- Framebuffers and depth
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
boolean | isFrameActive() default | If true, a frame is begun; true by default. |
boolean | canWrap(TextureWrap wrap) default | If true, the API samples with that wrap; true by default. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
void | withState(Consumer | Runs the body between pushState() and popState(), even when it throws. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | screen(int width, int height) abstract | Targets the window: no framebuffer, a viewport of that size in screen pixels, and an orthographic projection from the top-left corner with depth from 0 to 10000. |
void | quantize(double motionX, double motionY) abstract | Moves the modelview so that a node that moves by that offset, in the current coordinates, lands on whole screen pixels. |
void | pushState() abstract | Saves a copy of the render state. |
void | popState() abstract | Loads the last saved copy back into the same render state instance. |
int | getStateDepth() abstract | Returns the number of saved render states. |
void | clearDepth() abstract | Clears the depth of the current target to 1. |
void | clearStencil() abstract | Clears the stencil of the window to 0; does nothing when a framebuffer is the target. |
void | clearColor(float red, float green, float blue, float alpha) abstract | Clears the color of the current target, each channel from 0F to 1F; does nothing while color writes are off. |
void | draw(Primitive primitive, VertexBuffer buffer) abstract | Draws the vertices as triangles or lines with the current shader, or the default one, and the current state. |
ITexture | createTexture() abstract | Returns an empty texture, to allocate then upload. |
IFrameBuffer | createFrameBuffer(int width, int height) abstract | Returns a framebuffer of that size in pixels, with a color texture and a depth buffer. |
IShader | createShader(ShaderSource vertex, ShaderSource fragment, BlendState blend) abstract | Returns a shader for the two parsed stages and that blend state. |
void | suspend(Runnable draw) abstract | Runs a drawing of the host with its own state, inside a JOID frame: the state and the pass in progress are set aside until the drawing returns. |
void | raster(IFrameBuffer target, int width, int height, Runnable draw) abstract | Runs a drawing of the host into a framebuffer of JOID at that pixel size, for DrawUtils.RASTER. |
RenderState | getState() abstract | Returns the live render state. |
PixelGrid | getPixelGrid() abstract | Returns the screen pixel grid of the current matrices and viewport. |
MatrixStack | getModelView() abstract | Returns the modelview matrix stack. |
MatrixStack | getProjection() abstract | Returns the projection matrix stack. |
void | beginFrame() hook default | Begins a frame; drawing and clearing happen only between beginFrame() and endFrame(). |
void | endFrame() hook default | Ends the frame and submits what it recorded; does nothing by default. |
Method details
Section titled “Method details”isFrameActive
Section titled “isFrameActive”boolean isFrameActive() default
If true, a frame is begun; true by default.
canWrap
Section titled “canWrap”boolean canWrap(TextureWrap wrap) default
If true, the API samples with that wrap; true by default.
When it returns false, JOID samples with CLAMP_TO_EDGE, and emulates CLAMP_TO_BORDER in the shaders.
withState
Section titled “withState”void withState(Consumer<IRenderBridge> body) default
Runs the body between pushState() and popState(), even when it throws.
screen
Section titled “screen”void screen(int width, int height) abstract
Targets the window: no framebuffer, a viewport of that size in screen pixels, and an orthographic projection from the top-left corner with depth from 0 to 10000.
UIBridgeRegistry.frame calls it when the window changes size.
quantize
Section titled “quantize”void quantize(double motionX, double motionY) abstract
Moves the modelview so that a node that moves by that offset, in the current coordinates, lands on whole screen pixels.
pushState
Section titled “pushState”void pushState() abstract
Saves a copy of the render state.
popState
Section titled “popState”void popState() abstract
Loads the last saved copy back into the same render state instance.
getStateDepth
Section titled “getStateDepth”int getStateDepth() abstract
Returns the number of saved render states.
clearDepth
Section titled “clearDepth”void clearDepth() abstract
Clears the depth of the current target to 1.
clearStencil
Section titled “clearStencil”void clearStencil() abstract
Clears the stencil of the window to 0; does nothing when a framebuffer is the target.
clearColor
Section titled “clearColor”void clearColor(float red, float green, float blue, float alpha) abstract
Clears the color of the current target, each channel from 0F to 1F; does nothing while color writes are off.
void draw(Primitive primitive, VertexBuffer buffer) abstract
Draws the vertices as triangles or lines with the current shader, or the default one, and the current state. Skips the draw when the shader is not active, the buffer is empty or the viewport has no area.
createTexture
Section titled “createTexture”ITexture createTexture() abstract
Returns an empty texture, to allocate then upload.
createFrameBuffer
Section titled “createFrameBuffer”IFrameBuffer createFrameBuffer(int width, int height) abstract
Returns a framebuffer of that size in pixels, with a color texture and a depth buffer.
createShader
Section titled “createShader”IShader createShader(ShaderSource vertex, ShaderSource fragment, BlendState blend) abstract
Returns a shader for the two parsed stages and that blend state.
suspend
Section titled “suspend”void suspend(Runnable draw) abstract
Runs a drawing of the host with its own state, inside a JOID frame: the state and the pass in progress are set aside until the drawing returns.
raster
Section titled “raster”void raster(IFrameBuffer target, int width, int height, Runnable draw) abstract
Runs a drawing of the host into a framebuffer of JOID at that pixel size, for DrawUtils.RASTER.
Throws an IllegalStateException outside a frame.
getState
Section titled “getState”RenderState getState() abstract
Returns the live render state.
getPixelGrid
Section titled “getPixelGrid”PixelGrid getPixelGrid() abstract
Returns the screen pixel grid of the current matrices and viewport.
getModelView
Section titled “getModelView”MatrixStack getModelView() abstract
Returns the modelview matrix stack.
getProjection
Section titled “getProjection”MatrixStack getProjection() abstract
Returns the projection matrix stack.
beginFrame
Section titled “beginFrame”void beginFrame() hook default
Begins a frame; drawing and clearing happen only between beginFrame() and endFrame().
Does nothing by default.
endFrame
Section titled “endFrame”void endFrame() hook default
Ends the frame and submits what it recorded; does nothing by default.
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
