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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    GL_ACTIVE_TEXTURE.
    static final int
    GL_ALWAYS.
    static final int
    GL_ARRAY_BUFFER.
    static final int
    GL_ARRAY_BUFFER_BINDING.
    static final int
    GL_BLEND.
    static final int
    GL_BLEND_DST_ALPHA.
    static final int
    GL_BLEND_DST_RGB.
    static final int
    GL_BLEND_SRC_ALPHA.
    static final int
    GL_BLEND_SRC_RGB.
    static final int
    GL_BYTE.
    static final int
    GL_COLOR_WRITEMASK.
    static final int
    GL_CULL_FACE.
    static final int
    GL_CURRENT_PROGRAM.
    static final int
    GL_DEPTH_TEST.
    static final int
    GL_DEPTH_WRITEMASK.
    static final int
    GL_ELEMENT_ARRAY_BUFFER.
    static final int
    GL_EQUAL.
    static final int
    GL_FLOAT.
    static final int
    GL_FRAGMENT_SHADER.
    static final int
    GL_FRAMEBUFFER_BINDING.
    static final int
    GL_KEEP.
    static final int
    GL_NOTEQUAL.
    static final int
    GL_ONE.
    static final int
    GL_ONE_MINUS_SRC_ALPHA.
    static final int
    GL_REPLACE.
    static final int
    GL_SCISSOR_BOX.
    static final int
    GL_SCISSOR_TEST.
    static final int
    GL_SRC_ALPHA.
    static final int
    GL_STATIC_DRAW.
    static final int
    GL_STENCIL_FAIL.
    static final int
    GL_STENCIL_FUNC.
    static final int
    GL_STENCIL_PASS_DEPTH_FAIL.
    static final int
    GL_STENCIL_PASS_DEPTH_PASS.
    static final int
    GL_STENCIL_REF.
    static final int
    GL_STENCIL_TEST.
    static final int
    GL_STENCIL_VALUE_MASK.
    static final int
    GL_STENCIL_WRITEMASK.
    static final int
    GL_STREAM_DRAW.
    static final int
    GL_TEXTURE_BINDING_2D.
    static final int
    GL_TEXTURE0.
    static final int
    GL_TRIANGLES.
    static final int
    GL_UNSIGNED_BYTE.
    static final int
    GL_UNSIGNED_INT.
    static final int
    GL_UNSIGNED_SHORT.
    static final int
    GL_VERTEX_ARRAY_BINDING.
    static final int
    GL_VERTEX_SHADER.
    static final int
    GL_VIEWPORT.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activeTexture(int unit)
    Selects the active texture unit.
    void
    bindBuffer(int target, int buffer)
    Binds a buffer.
    void
    bindFramebuffer(int framebuffer)
    Binds a framebuffer for drawing and reading.
    void
    bindTexture(int texture)
    Binds a 2D texture on the active unit.
    void
    bindVertexArray(int vao)
    Binds a vertex array object.
    void
    blendFuncSeparate(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha)
    Sets separate RGB and alpha blend factors.
    void
    bufferData(int target, ByteBuffer data, int usage)
    Uploads a buffer's whole contents, replacing its storage.
    void
    bufferStorage(int target, long size, int usage)
    Allocates, or orphans, a buffer's storage without data.
    void
    bufferSubData(int target, long offset, ByteBuffer data)
    Writes into part of a buffer.
    void
    bufferWriteUnsynchronized(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.
    void
    Clears the bound framebuffer's colour to transparent black, keeping the clear colour.
    void
    clearStencil(int value)
    Clears the bound framebuffer's stencil, keeping the clear value.
    void
    colorMask(boolean r, boolean g, boolean b, boolean a)
    Sets the colour write mask.
    int
    compileShader(int type, String source)
    Creates and compiles a shader.
    void
    copyToBoundTexture(int width, int height)
    Copies the bottom-left of the read framebuffer into the bound texture.
    int
    Creates 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.
    int
    createRgbTexture(int width, int height, ByteBuffer rgb)
    Creates a linear-filtered RGB8 texture.
    int
    Creates a vertex array object.
    void
    deleteBuffer(int buffer)
    Deletes a buffer object.
    void
    deleteFence(long sync)
    Deletes a fence.
    void
    deleteFramebuffer(int[] ids)
    void
    deleteProgram(int program)
    Deletes a program.
    void
    deleteShader(int shader)
    Deletes a shader.
    void
    deleteTexture(int texture)
    Deletes a texture.
    void
    Deletes a vertex array object.
    void
    depthMask(boolean write)
    Turns depth writes on or off.
    void
    drawArrays(int mode, int first, int count)
    Draws non-indexed primitives from the bound vertex array.
    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.
    void
    enableVertexAttrib(int index)
    Enables a vertex attribute in the bound vertex array.
    long
    Inserts a fence after the commands issued so far.
    int
    getInteger(int pname)
    Reads one integer state value.
    void
    getIntegers(int pname, int[] out)
    Reads an integer state vector.
    boolean
    isEnabled(int cap)
    Returns whether a capability is on.
    int
    linkProgram(int... shaders)
    Links a program from compiled shaders.
    void
    matrices(float[] modelView, float[] projection)
    Reads the host's current model-view and projection matrices, column-major.
    boolean
    programLinked(int program)
    Returns whether a program linked.
    programLog(int program)
    Returns a program's info log.
    void
    scissor(int x, int y, int width, int height)
    Sets the scissor box, in framebuffer pixels.
    void
    setEnabled(int cap, boolean on)
    Turns a capability on or off.
    boolean
    shaderCompiled(int shader)
    Returns whether a shader compiled.
    shaderLog(int shader)
    Returns a shader's info log.
    int
    Returns the stencil bits of the bound draw framebuffer.
    void
    stencilFunc(int func, int ref, int mask)
    Sets the stencil test.
    void
    stencilMask(int mask)
    Sets the stencil write mask.
    void
    stencilOp(int sfail, int dpfail, int dppass)
    Sets the stencil operations.
    void
    uniform1f(int location, float v)
    Sets a float uniform on the bound program.
    void
    uniform1i(int location, int v)
    Sets an int or sampler uniform on the bound program.
    void
    uniform2f(int location, float x, float y)
    Sets a vec2 uniform on the bound program.
    void
    uniform4f(int location, float x, float y, float z, float w)
    Sets a vec4 uniform on the bound program.
    int
    uniformLocation(int program, String name)
    Looks up a uniform.
    void
    uniformMatrix4(int location, float[] m)
    Sets a mat4 uniform on the bound program.
    void
    useProgram(int program)
    Binds a program.
    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.
    void
    viewport(int x, int y, int width, int height)
    Sets the viewport, in framebuffer pixels.
    boolean
    waitFence(long sync, long timeoutNanos)
    Waits for a fence, flushing commands first.
  • Field Details

  • 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 enum
      out - 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 floats
      projection - 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 capability
      on - 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 factor
      dstRgb - destination RGB factor
      srcAlpha - source alpha factor
      dstAlpha - 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 - left
      y - bottom
      width - width
      height - height
    • useProgram

      void useProgram(int program)
      Binds a program.
      Parameters:
      program - the program, or 0
    • compileShader

      int compileShader(int type, String source)
      Creates and compiles a shader.
      Parameters:
      type - VERTEX_SHADER or FRAGMENT_SHADER
      source - 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

      String shaderLog(int shader)
      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 from layout(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

      String programLog(int program)
      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

      int uniformLocation(int program, String name)
      Looks up a uniform.
      Parameters:
      program - the program
      name - 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 location
      v - the value
    • uniform1f

      void uniform1f(int location, float v)
      Sets a float uniform on the bound program.
      Parameters:
      location - the location
      v - the value
    • uniform2f

      void uniform2f(int location, float x, float y)
      Sets a vec2 uniform on the bound program.
      Parameters:
      location - the location
      x - x
      y - 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 location
      x - x
      y - y
      z - z
      w - w
    • uniformMatrix4

      void uniformMatrix4(int location, float[] m)
      Sets a mat4 uniform on the bound program.
      Parameters:
      location - the location
      m - 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 pixels
      height - height in pixels
      depthStencil - whether to attach a 24/8 depth-stencil buffer
      Returns:
      framebuffer, texture and renderbuffer names (renderbuffer 0 when none)
    • deleteFramebuffer

      void deleteFramebuffer(int[] ids)
      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_BUFFER or ELEMENT_ARRAY_BUFFER
      buffer - the name, or 0
    • bufferData

      void bufferData(int target, ByteBuffer data, int usage)
      Uploads a buffer's whole contents, replacing its storage.
      Parameters:
      target - the binding target
      data - the bytes, from position to limit
      usage - STREAM_DRAW or STATIC_DRAW
    • bufferStorage

      void bufferStorage(int target, long size, int usage)
      Allocates, or orphans, a buffer's storage without data.
      Parameters:
      target - the binding target
      size - the size in bytes
      usage - the usage hint
    • bufferSubData

      void bufferSubData(int target, long offset, ByteBuffer data)
      Writes into part of a buffer.
      Parameters:
      target - the binding target
      offset - the byte offset
      data - the bytes, from position to limit
    • bufferWriteUnsynchronized

      void bufferWriteUnsynchronized(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. The caller guarantees, with fences, that the GPU no longer reads that range.
      Parameters:
      target - the binding target
      offset - the byte offset
      data - 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 location
      size - components
      type - component type
      normalized - whether integers are normalized
      stride - bytes between vertices
      offset - 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 mode
      first - the first vertex
      count - 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 mode
      count - the index count
      type - the index type
      offset - byte offset into the element buffer
      baseVertex - 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 fence
      timeoutNanos - 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 - TEXTURE0 plus 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 pixels
      height - height in pixels
    • scissor

      void scissor(int x, int y, int width, int height)
      Sets the scissor box, in framebuffer pixels.
      Parameters:
      x - left
      y - bottom
      width - width
      height - height
    • createRgbTexture

      int createRgbTexture(int width, int height, ByteBuffer rgb)
      Creates a linear-filtered RGB8 texture.
      Parameters:
      width - width
      height - height
      rgb - 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 comparison
      ref - the reference value
      mask - the value mask
    • stencilOp

      void stencilOp(int sfail, int dpfail, int dppass)
      Sets the stencil operations.
      Parameters:
      sfail - on stencil fail
      dpfail - on depth fail
      dppass - 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 - red
      g - green
      b - blue
      a - alpha