GlRenderBridge
class GlRenderBridge
Extends: RenderBridge
Package: dev.joid.base.opengl.render · Module: base-opengl · Source: GlRenderBridge.java
Backends: LWJGL 2 LWJGL 3
The render bridge of OpenGL, shared by every OpenGL backend, which calls OpenGL through a binding and gives the host its state back.
Description
Section titled “Description”Create it with the context of JOID current on the calling thread: it reads the capabilities of the context at once and throws an IllegalStateException when there is none, or when the context is too old.
It draws into the framebuffer that was bound when the frame began, and every change it makes to the state goes through its GlStateGuard.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| GlRenderBridge(IGlBinding binding) | Creates the bridge over the OpenGL binding of your library, reads the capabilities of the current context and creates its vertex input. |
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
IGlBinding | getBinding() | Returns the binding wrapped by the state guard, through which every call of the bridge goes; call it rather than your own binding to draw with JOID’s state. |
GlStateGuard | getGuard() | Returns the state guard of the bridge. |
GlVertexInput | getVertexInput() | Returns the vertex buffer and the vertex array that every draw uses. |
GlCapabilities | getCapabilities() | Returns what the context offers. |
IGlMipmapBuilder | getMipmapBuilder() | Returns the mipmap builder: framebuffer blits when the context can blit, drawn quads otherwise. |
IGlFrameBufferBinding | getFrameBufferBinding() | Returns the journaled framebuffer binding of the family that the context offers. |
int | getScreenFrameBuffer() | Returns the framebuffer that was bound when the frame began, where JOID draws when no framebuffer of JOID is the target. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
ITexture | createTexture() | Returns an empty GlTexture. |
IFrameBuffer | createFrameBuffer(int width, int height) | Returns a GlFrameBuffer of that size in pixels. |
IShader | createShader(ShaderSource vertex, ShaderSource fragment, BlendState blend) | Returns a GlShader, translated to the GLSL dialect of the context. |
void | suspend(Runnable draw) | Gives the host its state back, runs the drawing, then takes the state again for JOID. |
void | raster(IFrameBuffer target, int width, int height, Runnable draw) | Runs a drawing of the host into a framebuffer of JOID, with a viewport of that size in pixels, and binds the previous framebuffers and viewport back after it. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | beginFrameCommands() hook protected | Remembers the framebuffer that the host bound, then enters the state guard. |
void | submitFrameCommands() hook protected | Exits the state guard, which gives the host its state back. |
void | clearDepthBuffer() hook protected | Clears the depth of the target, with depth writes on. |
void | clearStencilBuffer() hook protected | Clears the stencil of the target, with every stencil bit writable. |
void | clearColorBuffer(float red, float green, float blue, float alpha) hook protected | Clears the color of the target to that color, with every channel writable. |
void | drawPrimitive(Primitive primitive, VertexBuffer buffer, IShader current) hook protected | Applies the whole render state, binds the samplers that the shader declares, uploads the vertices and draws them; throws an IllegalStateException outside a frame. |
Inherited from RenderBridge (14)
getStateDepth · getPixelGrid · getModelView · getProjection · getState · isFrameActive · screen · quantize · pushState · popState · clearDepth · clearStencil · clearColor · draw
Inherited from IRenderBridge (2)
Creation details
Section titled “Creation details”GlRenderBridge
Section titled “GlRenderBridge”GlRenderBridge(IGlBinding binding)
Creates the bridge over the OpenGL binding of your library, reads the capabilities of the current context and creates its vertex input.
Method details
Section titled “Method details”getBinding
Section titled “getBinding”IGlBinding getBinding()
Returns the binding wrapped by the state guard, through which every call of the bridge goes; call it rather than your own binding to draw with JOID’s state.
getGuard
Section titled “getGuard”GlStateGuard getGuard()
Returns the state guard of the bridge.
getVertexInput
Section titled “getVertexInput”GlVertexInput getVertexInput()
Returns the vertex buffer and the vertex array that every draw uses.
getCapabilities
Section titled “getCapabilities”GlCapabilities getCapabilities()
Returns what the context offers.
getMipmapBuilder
Section titled “getMipmapBuilder”IGlMipmapBuilder getMipmapBuilder()
Returns the mipmap builder: framebuffer blits when the context can blit, drawn quads otherwise.
getFrameBufferBinding
Section titled “getFrameBufferBinding”IGlFrameBufferBinding getFrameBufferBinding()
Returns the journaled framebuffer binding of the family that the context offers.
getScreenFrameBuffer
Section titled “getScreenFrameBuffer”int getScreenFrameBuffer()
Returns the framebuffer that was bound when the frame began, where JOID draws when no framebuffer of JOID is the target.
createTexture
Section titled “createTexture”ITexture createTexture()
Returns an empty GlTexture.
createFrameBuffer
Section titled “createFrameBuffer”IFrameBuffer createFrameBuffer(int width, int height)
Returns a GlFrameBuffer of that size in pixels.
createShader
Section titled “createShader”IShader createShader(ShaderSource vertex, ShaderSource fragment, BlendState blend)
Returns a GlShader, translated to the GLSL dialect of the context.
suspend
Section titled “suspend”void suspend(Runnable draw)
Gives the host its state back, runs the drawing, then takes the state again for JOID.
raster
Section titled “raster”void raster(IFrameBuffer target, int width, int height, Runnable draw)
Runs a drawing of the host into a framebuffer of JOID, with a viewport of that size in pixels, and binds the previous framebuffers and viewport back after it.
beginFrameCommands
Section titled “beginFrameCommands”void beginFrameCommands() hook protected
Remembers the framebuffer that the host bound, then enters the state guard.
submitFrameCommands
Section titled “submitFrameCommands”void submitFrameCommands() hook protected
Exits the state guard, which gives the host its state back.
clearDepthBuffer
Section titled “clearDepthBuffer”void clearDepthBuffer() hook protected
Clears the depth of the target, with depth writes on.
clearStencilBuffer
Section titled “clearStencilBuffer”void clearStencilBuffer() hook protected
Clears the stencil of the target, with every stencil bit writable.
clearColorBuffer
Section titled “clearColorBuffer”void clearColorBuffer(float red, float green, float blue, float alpha) hook protected
Clears the color of the target to that color, with every channel writable.
drawPrimitive
Section titled “drawPrimitive”void drawPrimitive(Primitive primitive, VertexBuffer buffer, IShader current) hook protected
Applies the whole render state, binds the samplers that the shader declares, uploads the vertices and draws them; throws an IllegalStateException outside a frame.
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
