Interface GlBackend
- All Known Implementing Classes:
Gl41CoreBackend
public interface GlBackend
The OpenGL calls Helios makes, behind one seam.
Gl41CoreBackend implements it on an OpenGL 4.1 core profile context, the only target. Tests and
benchmarks use fakes. Integer constants are the standard OpenGL enum values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intGL_ACTIVE_TEXTURE.static final intGL_ALWAYS.static final intGL_ARRAY_BUFFER.static final intGL_ARRAY_BUFFER_BINDING.static final intGL_BLEND.static final intGL_BLEND_DST_ALPHA.static final intGL_BLEND_DST_RGB.static final intGL_BLEND_SRC_ALPHA.static final intGL_BLEND_SRC_RGB.static final intGL_BYTE.static final intGL_COLOR_WRITEMASK.static final intGL_CULL_FACE.static final intGL_CURRENT_PROGRAM.static final intGL_DEPTH_TEST.static final intGL_DEPTH_WRITEMASK.static final intGL_ELEMENT_ARRAY_BUFFER.static final intGL_EQUAL.static final intGL_FLOAT.static final intGL_FRAGMENT_SHADER.static final intGL_FRAMEBUFFER_BINDING.static final intGL_KEEP.static final intGL_NOTEQUAL.static final intGL_ONE.static final intGL_ONE_MINUS_SRC_ALPHA.static final intGL_REPLACE.static final intGL_SCISSOR_BOX.static final intGL_SCISSOR_TEST.static final intGL_SRC_ALPHA.static final intGL_STATIC_DRAW.static final intGL_STENCIL_FAIL.static final intGL_STENCIL_FUNC.static final intGL_STENCIL_PASS_DEPTH_FAIL.static final intGL_STENCIL_PASS_DEPTH_PASS.static final intGL_STENCIL_REF.static final intGL_STENCIL_TEST.static final intGL_STENCIL_VALUE_MASK.static final intGL_STENCIL_WRITEMASK.static final intGL_STREAM_DRAW.static final intGL_TEXTURE_BINDING_2D.static final intGL_TEXTURE0.static final intGL_TRIANGLES.static final intGL_UNSIGNED_BYTE.static final intGL_UNSIGNED_INT.static final intGL_UNSIGNED_SHORT.static final intGL_VERTEX_ARRAY_BINDING.static final intGL_VERTEX_SHADER.static final intGL_VIEWPORT. -
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 whatcreateFramebuffer(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.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
-
BLEND
static final int BLENDGL_BLEND.- See Also:
-
DEPTH_TEST
static final int DEPTH_TESTGL_DEPTH_TEST.- See Also:
-
CULL_FACE
static final int CULL_FACEGL_CULL_FACE.- See Also:
-
SCISSOR_TEST
static final int SCISSOR_TESTGL_SCISSOR_TEST.- See Also:
-
STENCIL_TEST
static final int STENCIL_TESTGL_STENCIL_TEST.- See Also:
-
ONE
static final int ONEGL_ONE.- See Also:
-
SRC_ALPHA
static final int SRC_ALPHAGL_SRC_ALPHA.- See Also:
-
ONE_MINUS_SRC_ALPHA
static final int ONE_MINUS_SRC_ALPHAGL_ONE_MINUS_SRC_ALPHA.- See Also:
-
VERTEX_SHADER
static final int VERTEX_SHADERGL_VERTEX_SHADER.- See Also:
-
FRAGMENT_SHADER
static final int FRAGMENT_SHADERGL_FRAGMENT_SHADER.- See Also:
-
CURRENT_PROGRAM
static final int CURRENT_PROGRAMGL_CURRENT_PROGRAM.- See Also:
-
FRAMEBUFFER_BINDING
static final int FRAMEBUFFER_BINDINGGL_FRAMEBUFFER_BINDING.- See Also:
-
ARRAY_BUFFER_BINDING
static final int ARRAY_BUFFER_BINDINGGL_ARRAY_BUFFER_BINDING.- See Also:
-
VERTEX_ARRAY_BINDING
static final int VERTEX_ARRAY_BINDINGGL_VERTEX_ARRAY_BINDING.- See Also:
-
DEPTH_WRITEMASK
static final int DEPTH_WRITEMASKGL_DEPTH_WRITEMASK.- See Also:
-
BLEND_SRC_RGB
static final int BLEND_SRC_RGBGL_BLEND_SRC_RGB.- See Also:
-
BLEND_DST_RGB
static final int BLEND_DST_RGBGL_BLEND_DST_RGB.- See Also:
-
BLEND_SRC_ALPHA
static final int BLEND_SRC_ALPHAGL_BLEND_SRC_ALPHA.- See Also:
-
BLEND_DST_ALPHA
static final int BLEND_DST_ALPHAGL_BLEND_DST_ALPHA.- See Also:
-
VIEWPORT
static final int VIEWPORTGL_VIEWPORT.- See Also:
-
ACTIVE_TEXTURE
static final int ACTIVE_TEXTUREGL_ACTIVE_TEXTURE.- See Also:
-
TEXTURE0
static final int TEXTURE0GL_TEXTURE0.- See Also:
-
TEXTURE_BINDING_2D
static final int TEXTURE_BINDING_2DGL_TEXTURE_BINDING_2D.- See Also:
-
SCISSOR_BOX
static final int SCISSOR_BOXGL_SCISSOR_BOX.- See Also:
-
COLOR_WRITEMASK
static final int COLOR_WRITEMASKGL_COLOR_WRITEMASK.- See Also:
-
ARRAY_BUFFER
static final int ARRAY_BUFFERGL_ARRAY_BUFFER.- See Also:
-
ELEMENT_ARRAY_BUFFER
static final int ELEMENT_ARRAY_BUFFERGL_ELEMENT_ARRAY_BUFFER.- See Also:
-
STREAM_DRAW
static final int STREAM_DRAWGL_STREAM_DRAW.- See Also:
-
STATIC_DRAW
static final int STATIC_DRAWGL_STATIC_DRAW.- See Also:
-
TRIANGLES
static final int TRIANGLESGL_TRIANGLES.- See Also:
-
FLOAT
static final int FLOATGL_FLOAT.- See Also:
-
BYTE
static final int BYTEGL_BYTE.- See Also:
-
UNSIGNED_BYTE
static final int UNSIGNED_BYTEGL_UNSIGNED_BYTE.- See Also:
-
UNSIGNED_SHORT
static final int UNSIGNED_SHORTGL_UNSIGNED_SHORT.- See Also:
-
UNSIGNED_INT
static final int UNSIGNED_INTGL_UNSIGNED_INT.- See Also:
-
STENCIL_FUNC
static final int STENCIL_FUNCGL_STENCIL_FUNC.- See Also:
-
STENCIL_VALUE_MASK
static final int STENCIL_VALUE_MASKGL_STENCIL_VALUE_MASK.- See Also:
-
STENCIL_FAIL
static final int STENCIL_FAILGL_STENCIL_FAIL.- See Also:
-
STENCIL_PASS_DEPTH_FAIL
static final int STENCIL_PASS_DEPTH_FAILGL_STENCIL_PASS_DEPTH_FAIL.- See Also:
-
STENCIL_PASS_DEPTH_PASS
static final int STENCIL_PASS_DEPTH_PASSGL_STENCIL_PASS_DEPTH_PASS.- See Also:
-
STENCIL_REF
static final int STENCIL_REFGL_STENCIL_REF.- See Also:
-
STENCIL_WRITEMASK
static final int STENCIL_WRITEMASKGL_STENCIL_WRITEMASK.- See Also:
-
ALWAYS
static final int ALWAYSGL_ALWAYS.- See Also:
-
EQUAL
static final int EQUALGL_EQUAL.- See Also:
-
NOTEQUAL
static final int NOTEQUALGL_NOTEQUAL.- See Also:
-
KEEP
static final int KEEPGL_KEEP.- See Also:
-
REPLACE
static final int REPLACEGL_REPLACE.- See Also:
-
-
Method Details
-
getInteger
int getInteger(int pname) Reads one integer state value.- Parameters:
pname- the state enum- Returns:
- the value
-
getIntegers
void getIntegers(int pname, int[] out) Reads an integer state vector.- Parameters:
pname- the state enumout- receives the values
-
matrices
void matrices(float[] modelView, float[] projection) Reads 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.- Parameters:
modelView- receives the model-view matrix, 16 floatsprojection- receives the projection matrix, 16 floats
-
isEnabled
boolean isEnabled(int cap) Returns whether a capability is on.- Parameters:
cap- the capability- Returns:
- true when enabled
-
setEnabled
void setEnabled(int cap, boolean on) Turns a capability on or off.- Parameters:
cap- the capabilityon- the new state
-
blendFuncSeparate
void blendFuncSeparate(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha) Sets separate RGB and alpha blend factors.- Parameters:
srcRgb- source RGB factordstRgb- destination RGB factorsrcAlpha- source alpha factordstAlpha- destination alpha factor
-
depthMask
void depthMask(boolean write) Turns depth writes on or off.- Parameters:
write- the new state
-
viewport
void viewport(int x, int y, int width, int height) Sets the viewport, in framebuffer pixels.- Parameters:
x- lefty- bottomwidth- widthheight- height
-
useProgram
void useProgram(int program) Binds a program.- Parameters:
program- the program, or 0
-
compileShader
Creates and compiles a shader.- Parameters:
type-VERTEX_SHADERorFRAGMENT_SHADERsource- the full source- Returns:
- the shader name
-
shaderCompiled
boolean shaderCompiled(int shader) Returns whether a shader compiled.- Parameters:
shader- the shader- Returns:
- true on success
-
shaderLog
Returns a shader's info log.- Parameters:
shader- the shader- Returns:
- the log
-
deleteShader
void deleteShader(int shader) Deletes a shader.- Parameters:
shader- the shader
-
linkProgram
int linkProgram(int... shaders) Links a program from compiled shaders. Attribute and output locations come fromlayout(location)qualifiers in the source.- Parameters:
shaders- the shaders- Returns:
- the program name
-
programLinked
boolean programLinked(int program) Returns whether a program linked.- Parameters:
program- the program- Returns:
- true on success
-
programLog
Returns a program's info log.- Parameters:
program- the program- Returns:
- the log
-
deleteProgram
void deleteProgram(int program) Deletes a program.- Parameters:
program- the program
-
uniformLocation
Looks up a uniform.- Parameters:
program- the programname- the uniform name- Returns:
- the location, or -1
-
uniform1i
void uniform1i(int location, int v) Sets an int or sampler uniform on the bound program.- Parameters:
location- the locationv- the value
-
uniform1f
void uniform1f(int location, float v) Sets a float uniform on the bound program.- Parameters:
location- the locationv- the value
-
uniform2f
void uniform2f(int location, float x, float y) Sets a vec2 uniform on the bound program.- Parameters:
location- the locationx- xy- y
-
uniform4f
void uniform4f(int location, float x, float y, float z, float w) Sets a vec4 uniform on the bound program.- Parameters:
location- the locationx- xy- yz- zw- w
-
uniformMatrix4
void uniformMatrix4(int location, float[] m) Sets a mat4 uniform on the bound program.- Parameters:
location- the locationm- the matrix, column-major
-
createFramebuffer
int[] createFramebuffer(int width, int height, boolean depthStencil) Creates a framebuffer with an RGBA8 colour texture and optionally a depth-stencil renderbuffer. Leaves the previous bindings in place.- 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
void deleteFramebuffer(int[] ids) Deletes whatcreateFramebuffer(int, int, boolean)made.- Parameters:
ids- the names it returned
-
bindFramebuffer
void bindFramebuffer(int framebuffer) Binds a framebuffer for drawing and reading.- Parameters:
framebuffer- the framebuffer, or 0 for the default
-
clearColorTransparent
void clearColorTransparent()Clears the bound framebuffer's colour to transparent black, keeping the clear colour. -
createVertexArray
int createVertexArray()Creates a vertex array object.- Returns:
- its name
-
deleteVertexArray
void deleteVertexArray(int vao) Deletes a vertex array object.- Parameters:
vao- the name
-
bindVertexArray
void bindVertexArray(int vao) Binds a vertex array object.- Parameters:
vao- the name, or 0
-
createBuffer
int createBuffer()Creates a buffer object.- Returns:
- its name
-
deleteBuffer
void deleteBuffer(int buffer) Deletes a buffer object.- Parameters:
buffer- the name
-
bindBuffer
void bindBuffer(int target, int buffer) Binds a buffer.- Parameters:
target-ARRAY_BUFFERorELEMENT_ARRAY_BUFFERbuffer- the name, or 0
-
bufferData
Uploads a buffer's whole contents, replacing its storage.- Parameters:
target- the binding targetdata- the bytes, from position to limitusage-STREAM_DRAWorSTATIC_DRAW
-
bufferStorage
void bufferStorage(int target, long size, int usage) Allocates, or orphans, a buffer's storage without data.- Parameters:
target- the binding targetsize- the size in bytesusage- the usage hint
-
bufferSubData
Writes into part of a buffer.- Parameters:
target- the binding targetoffset- the byte offsetdata- the bytes, from position to limit
-
bufferWriteUnsynchronized
Writes 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.- Parameters:
target- the binding targetoffset- the byte offsetdata- the bytes, from position to limit
-
enableVertexAttrib
void enableVertexAttrib(int index) Enables a vertex attribute in the bound vertex array.- Parameters:
index- the attribute location
-
vertexAttribPointer
void vertexAttribPointer(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.- Parameters:
index- the attribute locationsize- componentstype- component typenormalized- whether integers are normalizedstride- bytes between verticesoffset- byte offset of the first component
-
drawArrays
void drawArrays(int mode, int first, int count) Draws non-indexed primitives from the bound vertex array.- Parameters:
mode- the primitive modefirst- the first vertexcount- the vertex count
-
drawElements
void drawElements(int mode, int count, int type, long offset, int baseVertex) Draws indexed primitives from the bound vertex array, adding a base to every index.- Parameters:
mode- the primitive modecount- the index counttype- the index typeoffset- byte offset into the element bufferbaseVertex- added to every index
-
fence
long fence()Inserts a fence after the commands issued so far.- Returns:
- the sync object
-
waitFence
boolean waitFence(long sync, long timeoutNanos) Waits for a fence, flushing commands first.- Parameters:
sync- the fencetimeoutNanos- the longest wait- Returns:
- true when the fence signalled
-
deleteFence
void deleteFence(long sync) Deletes a fence.- Parameters:
sync- the fence
-
activeTexture
void activeTexture(int unit) Selects the active texture unit.- Parameters:
unit-TEXTURE0plus the unit
-
bindTexture
void bindTexture(int texture) Binds a 2D texture on the active unit.- Parameters:
texture- the name, or 0
-
copyToBoundTexture
void copyToBoundTexture(int width, int height) Copies the bottom-left of the read framebuffer into the bound texture.- Parameters:
width- width in pixelsheight- height in pixels
-
scissor
void scissor(int x, int y, int width, int height) Sets the scissor box, in framebuffer pixels.- Parameters:
x- lefty- bottomwidth- widthheight- height
-
createRgbTexture
Creates a linear-filtered RGB8 texture.- Parameters:
width- widthheight- heightrgb- tightly packed RGB bytes- Returns:
- the texture name
-
deleteTexture
void deleteTexture(int texture) Deletes a texture.- Parameters:
texture- the name
-
stencilBits
int stencilBits()Returns the stencil bits of the bound draw framebuffer.- Returns:
- the bit count, 0 when there is no stencil buffer
-
stencilFunc
void stencilFunc(int func, int ref, int mask) Sets the stencil test.- Parameters:
func- the comparisonref- the reference valuemask- the value mask
-
stencilOp
void stencilOp(int sfail, int dpfail, int dppass) Sets the stencil operations.- Parameters:
sfail- on stencil faildpfail- on depth faildppass- on pass
-
stencilMask
void stencilMask(int mask) Sets the stencil write mask.- Parameters:
mask- the mask
-
clearStencil
void clearStencil(int value) Clears the bound framebuffer's stencil, keeping the clear value.- Parameters:
value- the value to clear to
-
colorMask
void colorMask(boolean r, boolean g, boolean b, boolean a) Sets the colour write mask.- Parameters:
r- redg- greenb- bluea- alpha
-