Kgl
Properties
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).
#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).
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.
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.
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.
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.
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.
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
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.
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.
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).
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+.
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.
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.
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.
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.
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.
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+.