LwjglKgl

class LwjglKgl : Kgl

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Preprocessor prefix that opts a shader into dFdx / dFdy. Defines our private WW_HAS_DERIVATIVES macro plus, where needed, emits the GLES extension directive. Shaders gate the derivative call site with #ifdef WW_HAS_DERIVATIVES rather than the reserved GL_OES_standard_derivatives (GLSL forbids user #define of GL_* names).

Link copied to clipboard
open override val glslVersion: String
Link copied to clipboard

#version directive for shaders that need GLES 3 / GL 3.3+ features (e.g. texelFetch, sized R32F sampling). Returns "#version 300 es\n" on Android / WebGL2 / iOS, where legacy glslVersion is empty. Falls back to glslVersion on platforms that already default to a modern directive (JOGL emits #version 330 core\n).

Link copied to clipboard
open override val hasMaliOOMBug: Boolean = false
Link copied to clipboard

True when receiver shaders may use sampler2DShadow hardware depth-compare sampling (needs a GLES 3 / WebGL 2 / GL 3.3 core shader path). Platforms whose glslVersion3 is unconditionally non-empty but whose context may be legacy (WebGL1) must override.

Link copied to clipboard

Largest float color-buffer precision that is render-target complete on this GL implementation. 32 =>GL_RGBA32F is renderable (desktop GL3+ / WebGL2 with EXT_color_buffer_float / Android+iOS-device GLES3 with the same extension); 16 => only GL_RGBA16F is renderable (some iOS Simulator GLES3 builds, GLES2 with EXT_color_buffer_half_float); 0 => no float color attachment is renderable and consumers must fall back to GL_RGBA8.

Link copied to clipboard

true when GL_LINEAR filtering is valid on a 32-bit-float colour texture. RGBA32F + GL_LINEAR is texture-complete only with OES_texture_float_linear / EXT_texture_float_linear; without it the sampler returns the incomplete-texture default (0,0,0,1) (Adreno 540 / Samsung S9 hits this). Callers that allocate RGBA32F must fall back to GL_NEAREST when this is false. No engine consumer since the shadow and sightline pipelines moved to plain depth textures; retained as public capability API. Always true on desktop GL3+; Android / iOS / WebGL query at runtime.

Link copied to clipboard
open override val supportsMultisampleFBO: Boolean

true on GLES3+ / GL3+ / WebGL2 — runtimes where multisample renderbuffers and blitFramebuffer resolves are available. The MSAA methods below (renderbufferStorageMultisample, framebufferRenderbuffer, blitFramebuffer) may throw when this is false; guard call sites with this flag.

Link copied to clipboard

true when one buffer object may be bound to both GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER over its lifetime. Desktop GL / GLES / iOS allow it, so the 3D Tiles path packs vertices + indices into one buffer bound to both (one mmap/primitive). WebGL forbids rebinding a buffer to a second target, so there callers keep indices in a dedicated GL_ELEMENT_ARRAY_BUFFER. true here; the WebGL backends override to false.

Link copied to clipboard

true on GLES3+ / GL3+ / WebGL2 — runtimes where texImage2D accepts sized internalformat values (e.g. GL_RGBA8, GL_DEPTH_COMPONENT16). WebGL1 / GLES2 require unsized formats where internalformat == format. Sized formats are needed for MSAA-resolve compatibility (the resolve target's internal format must match the multisample renderbuffer's GL_RGBA8).

Functions

Link copied to clipboard
open override fun activeTexture(texture: Int)
Link copied to clipboard
open override fun attachShader(program: KglProgram, shader: KglShader)
Link copied to clipboard
open override fun bindAttribLocation(program: KglProgram, index: Int, name: String)
Link copied to clipboard
open override fun bindBuffer(target: Int, buffer: KglBuffer)
Link copied to clipboard
open override fun bindFramebuffer(target: Int, framebuffer: KglFramebuffer)
Link copied to clipboard
open override fun bindRenderbuffer(target: Int, renderbuffer: KglRenderbuffer)
Link copied to clipboard
open override fun bindTexture(target: Int, texture: KglTexture)
Link copied to clipboard
open override fun blendFunc(sFactor: Int, dFactor: Int)
Link copied to clipboard
open override fun blitFramebuffer(srcX0: Int, srcY0: Int, srcX1: Int, srcY1: Int, dstX0: Int, dstY0: Int, dstX1: Int, dstY1: Int, mask: Int, filter: Int)
Link copied to clipboard
open override fun bufferData(target: Int, size: Int, usage: Int)

Allocate-only bufferData used for round-tripping pixel pack buffers (GL_STREAM_READ): reserves size bytes on the GPU without uploading source data. Pair with readPixelsToBuffer to write the framebuffer into the bound PBO and getBufferSubData to drain it back to CPU once a fence has signalled.

open override fun bufferData(target: Int, size: Int, sourceData: ByteArray?, usage: Int, offset: Int = 0)

Byte-typed bufferData overload — used to upload pre-packed pixel bytes (e.g. a decoded video frame) into a GL_PIXEL_UNPACK_BUFFER for an asynchronous texSubImage2D DMA into a texture.

open override fun bufferData(target: Int, size: Int, sourceData: FloatArray?, usage: Int, offset: Int = 0)
open override fun bufferData(target: Int, size: Int, sourceData: IntArray?, usage: Int, offset: Int = 0)
open override fun bufferData(target: Int, size: Int, sourceData: ShortArray?, usage: Int, offset: Int = 0)
Link copied to clipboard
open override fun bufferSubData(target: Int, offset: Int, size: Int, sourceData: ByteArray)
open override fun bufferSubData(target: Int, offset: Int, size: Int, sourceData: FloatArray)
open override fun bufferSubData(target: Int, offset: Int, size: Int, sourceData: IntArray)
open override fun bufferSubData(target: Int, offset: Int, size: Int, sourceData: ShortArray)
Link copied to clipboard
open override fun checkFramebufferStatus(target: Int): Int
Link copied to clipboard
open override fun clear(mask: Int)
Link copied to clipboard
open override fun clearColor(r: Float, g: Float, b: Float, a: Float)
Link copied to clipboard
open override fun clearStencil(s: Int)
Link copied to clipboard
open override fun colorMask(r: Boolean, g: Boolean, b: Boolean, a: Boolean)
Link copied to clipboard
open override fun compileShader(shader: KglShader)
Link copied to clipboard
open override fun createBuffer(): KglBuffer
Link copied to clipboard
open override fun createFramebuffer(): KglFramebuffer
Link copied to clipboard
open override fun createProgram(): KglProgram
Link copied to clipboard
open override fun createRenderbuffer(): KglRenderbuffer
Link copied to clipboard
open override fun createShader(type: Int): KglShader
Link copied to clipboard
open override fun createTexture(): KglTexture
Link copied to clipboard
open override fun cullFace(mode: Int)
Link copied to clipboard
open override fun deleteBuffer(buffer: KglBuffer)
Link copied to clipboard
open override fun deleteFramebuffer(framebuffer: KglFramebuffer)
Link copied to clipboard
open override fun deleteProgram(program: KglProgram)
Link copied to clipboard
open override fun deleteRenderbuffer(renderbuffer: KglRenderbuffer)
Link copied to clipboard
open override fun deleteShader(shader: KglShader)
Link copied to clipboard
open override fun deleteSync(sync: KglSync)
Link copied to clipboard
open override fun deleteTexture(texture: KglTexture)
Link copied to clipboard
open override fun depthFunc(func: Int)
Link copied to clipboard
open override fun depthMask(mask: Boolean)
Link copied to clipboard
open override fun disable(cap: Int)
Link copied to clipboard
open override fun disableVertexAttribArray(location: Int)
Link copied to clipboard
open override fun drawArrays(mode: Int, first: Int, count: Int)
Link copied to clipboard
open override fun drawBuffers(bufs: IntArray)

glDrawBuffers — selects the colour buffers the bound framebuffer draws into. Pass [GL_NONE] to make a depth-only framebuffer complete on desktop GL (which otherwise reports FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER for the default GL_COLOR_ATTACHMENT0). Requires GLES3+ / WebGL2 / GL3+; no-op where unsupported (callers gate on supportsSizedTextureFormats).

Link copied to clipboard
open override fun drawElements(mode: Int, count: Int, type: Int, offset: Int)
Link copied to clipboard
open override fun enable(cap: Int)
Link copied to clipboard
open override fun enableVertexAttribArray(location: Int)
Link copied to clipboard
open override fun fenceSync(): KglSync

Insert a GL_SYNC_GPU_COMMANDS_COMPLETE fence into the GL command stream. Pair with isSyncSignalled to test whether all preceding commands have finished, then deleteSync to release. Requires GLES3+ / WebGL2 / GL3+.

Link copied to clipboard
open override fun finish()
Link copied to clipboard
open override fun framebufferRenderbuffer(target: Int, attachment: Int, renderbufferTarget: Int, renderbuffer: KglRenderbuffer)
Link copied to clipboard
open override fun framebufferTexture2D(target: Int, attachment: Int, textarget: Int, texture: KglTexture, level: Int)
Link copied to clipboard
open override fun frontFace(mode: Int)
Link copied to clipboard
open override fun generateMipmap(target: Int)
Link copied to clipboard
open override fun getBufferSubData(target: Int, srcOffset: Int, dst: ByteArray)

Drain bytes from the buffer object bound to target (e.g. GL_PIXEL_PACK_BUFFER) into dst, starting at byte srcOffset within the buffer object. Blocks if the GPU is still writing the source range; the typical pattern is to wait for fenceSync to signal first.

Link copied to clipboard
open override fun getError(): Int
Link copied to clipboard
open override fun getParameterf(pname: Int): Float
Link copied to clipboard
open override fun getParameterfv(pname: Int): FloatArray
Link copied to clipboard
open override fun getParameteri(pname: Int): Int
Link copied to clipboard
open override fun getParameteriv(pname: Int): IntArray
Link copied to clipboard
open override fun getProgramInfoLog(program: KglProgram): String
Link copied to clipboard
open override fun getProgramParameteri(program: KglProgram, pname: Int): Int
Link copied to clipboard
open override fun getShaderInfoLog(shader: KglShader): String
Link copied to clipboard
open override fun getShaderParameteri(shader: KglShader, pname: Int): Int
Link copied to clipboard
open override fun getUniformLocation(program: KglProgram, name: String): KglUniformLocation
Link copied to clipboard
open override fun isSyncSignalled(sync: KglSync): Boolean

Non-blocking probe for sync: returns true once the fence has signalled (i.e. all GL commands issued before fenceSync have completed). Internally glClientWaitSync(sync, 0, 0) with no flush.

Link copied to clipboard
open override fun lineWidth(width: Float)
Link copied to clipboard
open override fun linkProgram(program: KglProgram)
Link copied to clipboard
open override fun mapAndCopyBufferRange(target: Int, offset: Int, length: Int, source: ByteArray, srcOffset: Int = 0, access: Int)

Upload length bytes from source (starting at srcOffset) into the buffer object currently bound to target, at byte offset within the buffer. Implemented via glMapBufferRange(... access) + memcpy + glUnmapBuffer where supported (JVM / Android with GLES3+); falls back to bufferSubData on JS / older runtimes.

Link copied to clipboard
open override fun pixelStorei(pname: Int, param: Int)
Link copied to clipboard
open override fun polygonOffset(factor: Float, units: Float)
Link copied to clipboard
open override fun readBuffer(src: Int)

glReadBuffer — selects the colour buffer for read operations on the bound framebuffer. Pair readBuffer(GL_NONE) with drawBuffers for depth-only framebuffers. Requires GLES3+ / WebGL2 / GL3+; no-op where unsupported.

Link copied to clipboard
open override fun readPixels(x: Int, y: Int, width: Int, height: Int, format: Int, type: Int, buffer: ByteArray)
Link copied to clipboard
open override fun readPixelsToBuffer(x: Int, y: Int, width: Int, height: Int, format: Int, type: Int, offset: Int)

glReadPixels variant that writes into the buffer currently bound to GL_PIXEL_PACK_BUFFER at byte offset from its start. Non-blocking on the CPU side - the GPU continues to fill the PBO asynchronously. Pair with fenceSync / isSyncSignalled to know when the data is ready, then getBufferSubData to drain it. Requires GLES3+ / WebGL2 / GL3+; falls back to a synchronous CPU-target readPixels is the responsibility of the caller when those features aren't available.

Link copied to clipboard
open override fun renderbufferStorageMultisample(target: Int, samples: Int, internalFormat: Int, width: Int, height: Int)
Link copied to clipboard
open override fun shaderSource(shader: KglShader, source: String)
Link copied to clipboard
open override fun stencilFunc(func: Int, ref: Int, mask: Int)
Link copied to clipboard
open override fun stencilMask(mask: Int)
Link copied to clipboard
open override fun stencilOp(fail: Int, zFail: Int, zPass: Int)
Link copied to clipboard
open override fun texImage2D(target: Int, level: Int, internalFormat: Int, width: Int, height: Int, border: Int, format: Int, type: Int, buffer: ByteArray?)

open override fun texImage2D(target: Int, level: Int, internalFormat: Int, width: Int, height: Int, border: Int, format: Int, type: Int, buffer: FloatArray?)

Float-typed texImage2D overload for sized formats like GL_R32F whose type is GL_FLOAT. Each platform wraps the buffer in its native float view (Float32Array on JS, FloatBuffer on JVM/Android) without an intermediate byte copy.

Link copied to clipboard
open override fun texParameteri(target: Int, pname: Int, value: Int)
Link copied to clipboard
open override fun texSubImage2D(target: Int, level: Int, xoffset: Int, yoffset: Int, width: Int, height: Int, format: Int, type: Int, buffer: ByteArray?)

Replace a sub-rectangle of an already-allocated 2D texture. Cheaper than texImage2D for steady-state video uploads — re-uploads pixels into existing storage rather than re-allocating the GPU image. Caller must ensure the texture was previously sized with texImage2D at the matching width/height.

open override fun texSubImage2D(target: Int, level: Int, xoffset: Int, yoffset: Int, width: Int, height: Int, format: Int, type: Int, offset: Int)

PBO variant: read pixels for texSubImage2D from the buffer currently bound to GL_PIXEL_UNPACK_BUFFER, starting at byte offset within the buffer object. The driver copies asynchronously, so the GL thread doesn't block on pixel transfer. Requires GLES3+ / WebGL2 / GL3+.

Link copied to clipboard
open override fun uniform1f(location: KglUniformLocation, f: Float)
Link copied to clipboard
open override fun uniform1fv(location: KglUniformLocation, count: Int, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun uniform1i(location: KglUniformLocation, i: Int)
Link copied to clipboard
open override fun uniform2f(location: KglUniformLocation, x: Float, y: Float)
Link copied to clipboard
open override fun uniform2fv(location: KglUniformLocation, count: Int, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun uniform2i(location: KglUniformLocation, x: Int, y: Int)
Link copied to clipboard
open override fun uniform3f(location: KglUniformLocation, x: Float, y: Float, z: Float)
Link copied to clipboard
open override fun uniform3fv(location: KglUniformLocation, count: Int, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun uniform3i(location: KglUniformLocation, x: Int, y: Int, z: Int)
Link copied to clipboard
open override fun uniform4f(location: KglUniformLocation, x: Float, y: Float, z: Float, w: Float)
Link copied to clipboard
open override fun uniform4fv(location: KglUniformLocation, count: Int, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun uniform4i(location: KglUniformLocation, x: Int, y: Int, z: Int, w: Int)
Link copied to clipboard
open override fun uniformMatrix3fv(location: KglUniformLocation, count: Int, transpose: Boolean, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun uniformMatrix4fv(location: KglUniformLocation, count: Int, transpose: Boolean, value: FloatArray, offset: Int)
Link copied to clipboard
open override fun useProgram(program: KglProgram)
Link copied to clipboard
open override fun vertexAttribPointer(location: Int, size: Int, type: Int, normalized: Boolean, stride: Int, offset: Int)
Link copied to clipboard
open override fun viewport(x: Int, y: Int, width: Int, height: Int)