Skip to content

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.

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.

ReturnsSignatureSummary
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.

ReturnsSignatureSummary
IGlBindinggetBinding()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.
GlStateGuardgetGuard()Returns the state guard of the bridge.
GlVertexInputgetVertexInput()Returns the vertex buffer and the vertex array that every draw uses.
GlCapabilitiesgetCapabilities()Returns what the context offers.
IGlMipmapBuildergetMipmapBuilder()Returns the mipmap builder: framebuffer blits when the context can blit, drawn quads otherwise.
IGlFrameBufferBindinggetFrameBufferBinding()Returns the journaled framebuffer binding of the family that the context offers.
intgetScreenFrameBuffer()Returns the framebuffer that was bound when the frame began, where JOID draws when no framebuffer of JOID is the target.
ReturnsSignatureSummary
ITexturecreateTexture()Returns an empty GlTexture.
IFrameBuffercreateFrameBuffer(int width, int height)Returns a GlFrameBuffer of that size in pixels.
IShadercreateShader(ShaderSource vertex, ShaderSource fragment, BlendState blend)Returns a GlShader, translated to the GLSL dialect of the context.
voidsuspend(Runnable draw)Gives the host its state back, runs the drawing, then takes the state again for JOID.
voidraster(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.
ReturnsSignatureSummary
voidbeginFrameCommands() hook protectedRemembers the framebuffer that the host bound, then enters the state guard.
voidsubmitFrameCommands() hook protectedExits the state guard, which gives the host its state back.
voidclearDepthBuffer() hook protectedClears the depth of the target, with depth writes on.
voidclearStencilBuffer() hook protectedClears the stencil of the target, with every stencil bit writable.
voidclearColorBuffer(float red, float green, float blue, float alpha) hook protectedClears the color of the target to that color, with every channel writable.
voiddrawPrimitive(Primitive primitive, VertexBuffer buffer, IShader current) hook protectedApplies 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)

canWrap · withState

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.

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.

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.

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.


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