Class Gl41CoreBackend
java.lang.Object
lol.trq.helios.gl.Gl41CoreBackend
- All Implemented Interfaces:
GlBackend
The backend on an OpenGL 4.1 core profile context, as Lazarus creates with
-Dlazarus.gl=core.
Binding calls go through GL15, GL20 and GL30 without the C suffix, which Lazarus
intercepts to keep its cache of the bound buffer, program and vertex array true. Draw calls go through the
C classes, because Lazarus sends GL11.glDrawArrays to its fixed-function emulator. Capability
toggles and texture binds use GL11 and GL13, which the emulator tracks without querying the driver.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intGL_CONTEXT_CORE_PROFILE_BIT.static final intGL_CONTEXT_PROFILE_MASK.Fields inherited from interface GlBackend
ACTIVE_TEXTURE, ALWAYS, ARRAY_BUFFER, ARRAY_BUFFER_BINDING, BLEND, BLEND_DST_ALPHA, BLEND_DST_RGB, BLEND_SRC_ALPHA, BLEND_SRC_RGB, BYTE, COLOR_WRITEMASK, CULL_FACE, CURRENT_PROGRAM, DEPTH_TEST, DEPTH_WRITEMASK, ELEMENT_ARRAY_BUFFER, EQUAL, FLOAT, FRAGMENT_SHADER, FRAMEBUFFER_BINDING, KEEP, NOTEQUAL, ONE, ONE_MINUS_SRC_ALPHA, REPLACE, SCISSOR_BOX, SCISSOR_TEST, SRC_ALPHA, STATIC_DRAW, STENCIL_FAIL, STENCIL_FUNC, STENCIL_PASS_DEPTH_FAIL, STENCIL_PASS_DEPTH_PASS, STENCIL_REF, STENCIL_TEST, STENCIL_VALUE_MASK, STENCIL_WRITEMASK, STREAM_DRAW, TEXTURE_BINDING_2D, TEXTURE0, TRIANGLES, UNSIGNED_BYTE, UNSIGNED_INT, UNSIGNED_SHORT, VERTEX_ARRAY_BINDING, VERTEX_SHADER, VIEWPORT -
Constructor Summary
ConstructorsConstructorDescriptionChecks the context and binds to the emulated matrix stacks. -
Method Summary
Modifier and TypeMethodDescriptionvoidactiveTexture(int unit) Selects the active texture unit.voidbindBuffer(int target, int buffer) Binds a buffer.voidbindFramebuffer(int framebuffer) Binds a framebuffer for drawing and reading.voidbindTexture(int texture) Binds a 2D texture on the active unit.voidbindVertexArray(int vao) Binds a vertex array object.voidblendFuncSeparate(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha) Sets separate RGB and alpha blend factors.voidbufferData(int target, ByteBuffer data, int usage) Uploads a buffer's whole contents, replacing its storage.voidbufferStorage(int target, long size, int usage) Allocates, or orphans, a buffer's storage without data.voidbufferSubData(int target, long offset, ByteBuffer data) Writes into part of a buffer.voidbufferWriteUnsynchronized(int target, long offset, ByteBuffer data) Writes into part of a buffer through an unsynchronized mapping that invalidates the range: no wait on the GPU.voidClears the bound framebuffer's colour to transparent black, keeping the clear colour.voidclearStencil(int value) Clears the bound framebuffer's stencil, keeping the clear value.voidcolorMask(boolean r, boolean g, boolean b, boolean a) Sets the colour write mask.intcompileShader(int type, String source) Creates and compiles a shader.voidcopyToBoundTexture(int width, int height) Copies the bottom-left of the read framebuffer into the bound texture.intCreates a buffer object.int[]createFramebuffer(int width, int height, boolean depthStencil) Creates a framebuffer with an RGBA8 colour texture and optionally a depth-stencil renderbuffer.intcreateRgbTexture(int width, int height, ByteBuffer rgb) Creates a linear-filtered RGB8 texture.intCreates a vertex array object.voiddeleteBuffer(int buffer) Deletes a buffer object.voiddeleteFence(long sync) Deletes a fence.voiddeleteFramebuffer(int[] ids) Deletes whatGlBackend.createFramebuffer(int, int, boolean)made.voiddeleteProgram(int program) Deletes a program.voiddeleteShader(int shader) Deletes a shader.voiddeleteTexture(int texture) Deletes a texture.voiddeleteVertexArray(int vao) Deletes a vertex array object.voiddepthMask(boolean write) Turns depth writes on or off.voiddrawArrays(int mode, int first, int count) Draws non-indexed primitives from the bound vertex array.voiddrawElements(int mode, int count, int type, long offset, int baseVertex) Draws indexed primitives from the bound vertex array, adding a base to every index.voidenableVertexAttrib(int index) Enables a vertex attribute in the bound vertex array.longfence()Inserts a fence after the commands issued so far.intgetInteger(int pname) Reads one integer state value.voidgetIntegers(int pname, int[] out) Reads an integer state vector.booleanisEnabled(int cap) Returns whether a capability is on.intlinkProgram(int... shaders) Links a program from compiled shaders.voidmatrices(float[] modelView, float[] projection) Reads the host's current model-view and projection matrices, column-major.booleanprogramLinked(int program) Returns whether a program linked.programLog(int program) Returns a program's info log.static voidChecks that the current context is an OpenGL 4.1 or later core profile.voidscissor(int x, int y, int width, int height) Sets the scissor box, in framebuffer pixels.voidsetEnabled(int cap, boolean on) Turns a capability on or off.booleanshaderCompiled(int shader) Returns whether a shader compiled.shaderLog(int shader) Returns a shader's info log.intReturns the stencil bits of the bound draw framebuffer.voidstencilFunc(int func, int ref, int mask) Sets the stencil test.voidstencilMask(int mask) Sets the stencil write mask.voidstencilOp(int sfail, int dpfail, int dppass) Sets the stencil operations.voiduniform1f(int location, float v) Sets a float uniform on the bound program.voiduniform1i(int location, int v) Sets an int or sampler uniform on the bound program.voiduniform2f(int location, float x, float y) Sets a vec2 uniform on the bound program.voiduniform4f(int location, float x, float y, float z, float w) Sets a vec4 uniform on the bound program.intuniformLocation(int program, String name) Looks up a uniform.voiduniformMatrix4(int location, float[] m) Sets a mat4 uniform on the bound program.voiduseProgram(int program) Binds a program.voidvertexAttribPointer(int index, int size, int type, boolean normalized, int stride, long offset) Describes a vertex attribute in the bound vertex array, reading from the bound array buffer.voidviewport(int x, int y, int width, int height) Sets the viewport, in framebuffer pixels.booleanwaitFence(long sync, long timeoutNanos) Waits for a fence, flushing commands first.
-
Field Details
-
CONTEXT_PROFILE_MASK
public static final int CONTEXT_PROFILE_MASKGL_CONTEXT_PROFILE_MASK.- See Also:
-
CONTEXT_CORE_PROFILE_BIT
public static final int CONTEXT_CORE_PROFILE_BITGL_CONTEXT_CORE_PROFILE_BIT.- See Also:
-
-
Constructor Details
-
Gl41CoreBackend
public Gl41CoreBackend()Checks the context and binds to the emulated matrix stacks.- Throws:
IllegalStateException- if the context is not OpenGL 4.1 core, or Lazarus core mode is not running
-
-
Method Details
-
requireCoreContext
public static void requireCoreContext()Checks that the current context is an OpenGL 4.1 or later core profile.- Throws:
IllegalStateException- with instructions when it is not
-
getInteger
public int getInteger(int pname) Description copied from interface:GlBackendReads one integer state value.- Specified by:
getIntegerin interfaceGlBackend- Parameters:
pname- the state enum- Returns:
- the value
-
getIntegers
public void getIntegers(int pname, int[] out) Description copied from interface:GlBackendReads an integer state vector.- Specified by:
getIntegersin interfaceGlBackend- Parameters:
pname- the state enumout- receives the values
-
matrices
public void matrices(float[] modelView, float[] projection) Description copied from interface:GlBackendReads the host's current model-view and projection matrices, column-major. On Lazarus core mode they come from the emulated matrix stacks without a driver query. -
isEnabled
-
setEnabled
public void setEnabled(int cap, boolean on) Description copied from interface:GlBackendTurns a capability on or off.- Specified by:
setEnabledin interfaceGlBackend- Parameters:
cap- the capabilityon- the new state
-
blendFuncSeparate
public void blendFuncSeparate(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha) Description copied from interface:GlBackendSets separate RGB and alpha blend factors.- Specified by:
blendFuncSeparatein interfaceGlBackend- Parameters:
srcRgb- source RGB factordstRgb- destination RGB factorsrcAlpha- source alpha factordstAlpha- destination alpha factor
-
depthMask
-
viewport
-
useProgram
public void useProgram(int program) Description copied from interface:GlBackendBinds a program.- Specified by:
useProgramin interfaceGlBackend- Parameters:
program- the program, or 0
-
compileShader
Description copied from interface:GlBackendCreates and compiles a shader.- Specified by:
compileShaderin interfaceGlBackend- Parameters:
type-GlBackend.VERTEX_SHADERorGlBackend.FRAGMENT_SHADERsource- the full source- Returns:
- the shader name
-
shaderCompiled
public boolean shaderCompiled(int shader) Description copied from interface:GlBackendReturns whether a shader compiled.- Specified by:
shaderCompiledin interfaceGlBackend- Parameters:
shader- the shader- Returns:
- true on success
-
shaderLog
-
deleteShader
public void deleteShader(int shader) Description copied from interface:GlBackendDeletes a shader.- Specified by:
deleteShaderin interfaceGlBackend- Parameters:
shader- the shader
-
linkProgram
public int linkProgram(int... shaders) Description copied from interface:GlBackendLinks a program from compiled shaders. Attribute and output locations come fromlayout(location)qualifiers in the source.- Specified by:
linkProgramin interfaceGlBackend- Parameters:
shaders- the shaders- Returns:
- the program name
-
programLinked
public boolean programLinked(int program) Description copied from interface:GlBackendReturns whether a program linked.- Specified by:
programLinkedin interfaceGlBackend- Parameters:
program- the program- Returns:
- true on success
-
programLog
Description copied from interface:GlBackendReturns a program's info log.- Specified by:
programLogin interfaceGlBackend- Parameters:
program- the program- Returns:
- the log
-
deleteProgram
public void deleteProgram(int program) Description copied from interface:GlBackendDeletes a program.- Specified by:
deleteProgramin interfaceGlBackend- Parameters:
program- the program
-
uniformLocation
Description copied from interface:GlBackendLooks up a uniform.- Specified by:
uniformLocationin interfaceGlBackend- Parameters:
program- the programname- the uniform name- Returns:
- the location, or -1
-
uniform1i
-
uniform1f
-
uniform2f
-
uniform4f
-
uniformMatrix4
public void uniformMatrix4(int location, float[] m) Description copied from interface:GlBackendSets a mat4 uniform on the bound program.- Specified by:
uniformMatrix4in interfaceGlBackend- Parameters:
location- the locationm- the matrix, column-major
-
createFramebuffer
public int[] createFramebuffer(int width, int height, boolean depthStencil) Description copied from interface:GlBackendCreates a framebuffer with an RGBA8 colour texture and optionally a depth-stencil renderbuffer. Leaves the previous bindings in place.- Specified by:
createFramebufferin interfaceGlBackend- Parameters:
width- width in pixelsheight- height in pixelsdepthStencil- whether to attach a 24/8 depth-stencil buffer- Returns:
- framebuffer, texture and renderbuffer names (renderbuffer 0 when none)
-
deleteFramebuffer
public void deleteFramebuffer(int[] ids) Description copied from interface:GlBackendDeletes whatGlBackend.createFramebuffer(int, int, boolean)made.- Specified by:
deleteFramebufferin interfaceGlBackend- Parameters:
ids- the names it returned
-
bindFramebuffer
public void bindFramebuffer(int framebuffer) Description copied from interface:GlBackendBinds a framebuffer for drawing and reading.- Specified by:
bindFramebufferin interfaceGlBackend- Parameters:
framebuffer- the framebuffer, or 0 for the default
-
clearColorTransparent
public void clearColorTransparent()Description copied from interface:GlBackendClears the bound framebuffer's colour to transparent black, keeping the clear colour.- Specified by:
clearColorTransparentin interfaceGlBackend
-
createVertexArray
public int createVertexArray()Description copied from interface:GlBackendCreates a vertex array object.- Specified by:
createVertexArrayin interfaceGlBackend- Returns:
- its name
-
deleteVertexArray
public void deleteVertexArray(int vao) Description copied from interface:GlBackendDeletes a vertex array object.- Specified by:
deleteVertexArrayin interfaceGlBackend- Parameters:
vao- the name
-
bindVertexArray
public void bindVertexArray(int vao) Description copied from interface:GlBackendBinds a vertex array object.- Specified by:
bindVertexArrayin interfaceGlBackend- Parameters:
vao- the name, or 0
-
createBuffer
public int createBuffer()Description copied from interface:GlBackendCreates a buffer object.- Specified by:
createBufferin interfaceGlBackend- Returns:
- its name
-
deleteBuffer
public void deleteBuffer(int buffer) Description copied from interface:GlBackendDeletes a buffer object.- Specified by:
deleteBufferin interfaceGlBackend- Parameters:
buffer- the name
-
bindBuffer
public void bindBuffer(int target, int buffer) Description copied from interface:GlBackendBinds a buffer.- Specified by:
bindBufferin interfaceGlBackend- Parameters:
target-GlBackend.ARRAY_BUFFERorGlBackend.ELEMENT_ARRAY_BUFFERbuffer- the name, or 0
-
bufferData
Description copied from interface:GlBackendUploads a buffer's whole contents, replacing its storage.- Specified by:
bufferDatain interfaceGlBackend- Parameters:
target- the binding targetdata- the bytes, from position to limitusage-GlBackend.STREAM_DRAWorGlBackend.STATIC_DRAW
-
bufferStorage
public void bufferStorage(int target, long size, int usage) Description copied from interface:GlBackendAllocates, or orphans, a buffer's storage without data.- Specified by:
bufferStoragein interfaceGlBackend- Parameters:
target- the binding targetsize- the size in bytesusage- the usage hint
-
bufferSubData
Description copied from interface:GlBackendWrites into part of a buffer.- Specified by:
bufferSubDatain interfaceGlBackend- Parameters:
target- the binding targetoffset- the byte offsetdata- the bytes, from position to limit
-
bufferWriteUnsynchronized
Description copied from interface:GlBackendWrites into part of a buffer through an unsynchronized mapping that invalidates the range: no wait on the GPU. The caller guarantees, with fences, that the GPU no longer reads that range.- Specified by:
bufferWriteUnsynchronizedin interfaceGlBackend- Parameters:
target- the binding targetoffset- the byte offsetdata- the bytes, from position to limit
-
enableVertexAttrib
public void enableVertexAttrib(int index) Description copied from interface:GlBackendEnables a vertex attribute in the bound vertex array.- Specified by:
enableVertexAttribin interfaceGlBackend- Parameters:
index- the attribute location
-
vertexAttribPointer
public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, long offset) Description copied from interface:GlBackendDescribes a vertex attribute in the bound vertex array, reading from the bound array buffer.- Specified by:
vertexAttribPointerin interfaceGlBackend- Parameters:
index- the attribute locationsize- componentstype- component typenormalized- whether integers are normalizedstride- bytes between verticesoffset- byte offset of the first component
-
drawArrays
public void drawArrays(int mode, int first, int count) Description copied from interface:GlBackendDraws non-indexed primitives from the bound vertex array.- Specified by:
drawArraysin interfaceGlBackend- Parameters:
mode- the primitive modefirst- the first vertexcount- the vertex count
-
drawElements
public void drawElements(int mode, int count, int type, long offset, int baseVertex) Description copied from interface:GlBackendDraws indexed primitives from the bound vertex array, adding a base to every index.- Specified by:
drawElementsin interfaceGlBackend- Parameters:
mode- the primitive modecount- the index counttype- the index typeoffset- byte offset into the element bufferbaseVertex- added to every index
-
fence
-
waitFence
-
deleteFence
public void deleteFence(long sync) Description copied from interface:GlBackendDeletes a fence.- Specified by:
deleteFencein interfaceGlBackend- Parameters:
sync- the fence
-
activeTexture
public void activeTexture(int unit) Description copied from interface:GlBackendSelects the active texture unit.- Specified by:
activeTexturein interfaceGlBackend- Parameters:
unit-GlBackend.TEXTURE0plus the unit
-
bindTexture
public void bindTexture(int texture) Description copied from interface:GlBackendBinds a 2D texture on the active unit.- Specified by:
bindTexturein interfaceGlBackend- Parameters:
texture- the name, or 0
-
copyToBoundTexture
public void copyToBoundTexture(int width, int height) Description copied from interface:GlBackendCopies the bottom-left of the read framebuffer into the bound texture.- Specified by:
copyToBoundTexturein interfaceGlBackend- Parameters:
width- width in pixelsheight- height in pixels
-
createRgbTexture
Description copied from interface:GlBackendCreates a linear-filtered RGB8 texture.- Specified by:
createRgbTexturein interfaceGlBackend- Parameters:
width- widthheight- heightrgb- tightly packed RGB bytes- Returns:
- the texture name
-
deleteTexture
public void deleteTexture(int texture) Description copied from interface:GlBackendDeletes a texture.- Specified by:
deleteTexturein interfaceGlBackend- Parameters:
texture- the name
-
stencilBits
public int stencilBits()Description copied from interface:GlBackendReturns the stencil bits of the bound draw framebuffer.- Specified by:
stencilBitsin interfaceGlBackend- Returns:
- the bit count, 0 when there is no stencil buffer
-
stencilFunc
public void stencilFunc(int func, int ref, int mask) Description copied from interface:GlBackendSets the stencil test.- Specified by:
stencilFuncin interfaceGlBackend- Parameters:
func- the comparisonref- the reference valuemask- the value mask
-
stencilOp
-
stencilMask
public void stencilMask(int mask) Description copied from interface:GlBackendSets the stencil write mask.- Specified by:
stencilMaskin interfaceGlBackend- Parameters:
mask- the mask
-
clearStencil
public void clearStencil(int value) Description copied from interface:GlBackendClears the bound framebuffer's stencil, keeping the clear value.- Specified by:
clearStencilin interfaceGlBackend- Parameters:
value- the value to clear to
-
colorMask
-
scissor
-