Draw Context
Properties
Monotonic counter incremented each time contextLost runs (typically Android pause / resume tearing down the GLSurfaceView's GL context). Renderables that own GPU handles outside earth.worldwind.render.RenderResourceCache can compare this against a cached value to detect that their handles are stale and need re-allocating. Propagated to earth.worldwind.render.RenderContext per frame by the engine.
Returns the name of the OpenGL framebuffer object that is currently active.
Returns the name of the OpenGL program object that is currently active.
Returns the name of the OpenGL texture 2D object currently bound to the active multitexture unit. The active multitexture unit may be determined by calling currentTextureUnit.
Returns the OpenGL multitexture unit that is currently active. Returns a value from the GL_TEXTUREi enumeration, where i ranges from 0 to 32.
1x1 RGBA cube-map (six faces) for binding to an empty samplerCube slot, the cube counterpart to defaultTexture. Lazily allocated and cached.
Returns 1x1 RGBA texture for binding to empty texture slot, initialized to 0
Pick-only depth-to-color packer; null on regular frames. See DepthToColorProgram.
Returns count of terrain drawables in queue
Per-frame snapshot of 3D-Tile mesh layer coverage sectors. Empty when hasGroundCoverageMask is false; consumed by BasicDrawableTerrain.
Mesh drawables that receive draped surface-shape textures this frame.
true when at least one 3D-Tile mesh layer enqueued into DrawableGroup.SURFACE this frame — terrain stencil-tests against GROUND_COVERED_BIT. Propagated from RC via Frame.
Frame stamp of the last ShadowState whose cascade textures were bound to texture units 1..4. Used by earth.worldwind.layer.shadow.applyShadowReceiverUniforms to skip the (cheap but redundant) activeTexture + bindTexture pairs after the first receiver in a frame. Reset to -1 on context reset.
Identity of the SightlineState whose depth cube is currently bound on unit 5. null after the binding is cleared on a no-sightline frame.
World-space (Cartesian) unit vector pointing toward the light source. Mirrors the value that earth.worldwind.render.RenderContext.lightDirection held at the end of the render phase (so any AtmosphereLayer override is preserved). Drawables typically multiply this by modelviewNormalTransform to get the eye-space light direction for shading.
Returns the multisample framebuffer used as the render target for surface shape rasterization, or null when the GL implementation doesn't support MSAA (WebGL1). Callers blit (resolve) into scratchFramebuffer's color attachment after rendering. Created lazily on first access and cached.
Cube counterpart of nullShadowDepthTexture for the sightline unit (samplerCubeShadow).
1x1 compare-mode depth texture bound to the cascade units when no shadow state is active. WebGL2 validates sampler type vs texture format at draw time even when the shader never samples (applyShadow false), so sampler2DShadow receivers must always see a compare-mode depth texture on units 1..4. Only used when Kgl.hasShadowSamplers.
Color-only FBO that receives DepthToColorProgram's RG-pack of pickFramebuffer's depth texture, since glReadPixels can't portably read DEPTH_COMPONENT on WebGL1 / GLES2. Allocate via ensurePickFramebuffer.
Pick-pass FBO: RGBA8 color (pick IDs) + DEPTH24 (DEPTH16 on WebGL1 / GLES2 fallback). Allocate via ensurePickFramebuffer. The depth precision controls how far from the camera a non-terrain pick can land before depth-readback drift recovers the surface point on the far clipping plane (Earth-scale view: antipode / under-ground artefacts).
Returns an OpenGL buffer object containing indices needed to render triangle Expected vertex data layout for this buffer is something like this 1 ---- 0 | /| | / | | / | | / | | / | 3 ---- 2
The OpenGL buffer object is created on first use and cached. Subsequent calls to this method return the cached buffer object.
Returns an OpenGL framebuffer object suitable for offscreen drawing. The framebuffer has a 32-bit color buffer and a 32-bit depth buffer, both attached as OpenGL texture 2D objects.
The framebuffer may be used by any drawable and for any purpose. However, the draw context makes no guarantees about the framebuffer's contents. Drawables must clear the framebuffer before use, and must assume its contents may be modified by another drawable, either during the current frame or in a subsequent frame.
The OpenGL framebuffer object is created on first use and cached. Subsequent calls to this method return the cached buffer object.
Returns a scratch list suitable for accumulating entries during drawing. The list is cleared before each frame, otherwise its contents are undefined.
Per-frame cascaded shadow map state. Non-null when earth.worldwind.layer.shadow.ShadowLayer is in the layer list; null otherwise (receivers should treat absence as "no shadows"). The state's cascade matrices and ambient factor drive the receiver shaders; the state also signals which shadow framebuffers (shadowCascadeFramebuffer) hold valid depth for this frame.
Whether benign 2D/cube textures are bound on units 5 / 6 this frame so the no-sightline path's never-sampled samplers don't trip macOS's empty-unit validator. Reset per frame.
Depth-only framebuffer paired with sightlineDepthCubeTexture. The depth pass re-attaches the face being rendered to GL_DEPTH_ATTACHMENT via Framebuffer.attachTexture with the matching GL_TEXTURE_CUBE_MAP_* target. With no colour attachment, desktop GL reports FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER unless the draw and read buffers are explicitly set to NONE (FBO state, set once here).
Identity of the sightline shape whose depth pass last filled sightlineDepthCubeTexture. With several sightlines in a scene each one's overlay pass re-renders the cube only when another sightline has overwritten it since its own depth pass ran.
Scratch for the camera-relative sightline matrix composed in earth.worldwind.layer.sightline.applySightlineReceiverUniforms. Owned by the draw context (not file scope) so each WorldWindow's GL thread composes into its own matrix - multiple windows draw concurrently on separate threads. Fully overwritten per use.
Per-frame sightline-receiver state. Populated by DrawableSightline when its depth pass runs (BACKGROUND group); read by every shape program that splices in earth.worldwind.layer.sightline.SightlineReceiverGlsl so the shape's own fragment shader can sample the depth cube and self-shadow without an overlay re-rasterisation.
True when sightline receivers read the cube through a plain samplerCube (no hardware depth-compare) — the depth pass then packs window depth into an RGBA8 color cube via earth.worldwind.render.program.PackedDepthProgram. Sampling a real DEPTH_COMPONENT texture through a plain sampler is driver-dependent — Adreno 512 returns ~8-bit quantized depth, collapsing the sightline's 1/d mapping into kilometre buckets — while RGBA8 color reads are exact on every GPU.
Draping program; non-null only on frames with groundOverlaySurfaces.
Per-terrain-tile composited surface-shape RTT textures, keyed by tile (sector + globe offset), bounded by SURFACE_SHAPE_CACHE_BYTES. Keyed by tile — NOT tile+shapes — so DrawableSurfaceShape reuses a tile's last fully-composited texture while its shapes reassemble (retain-last-good), avoiding both the base-layer flash on pan and the per-frame hash churn that filled the count-bounded texturesCache with 5 MB textures and OOM'd. Releases the GL texture on eviction or in-place replace.
This cache can be used to store runtime-generated textures by DrawContext thread
Returns an OpenGL buffer object containing a unit square expressed as four vertices at (0, 1), (0, 0), (1, 1) and (1, 0). Each vertex is stored as two 32-bit floating point coordinates. The four vertices are in the order required by a triangle strip.
The OpenGL buffer object is created on first use and cached. Subsequent calls to this method return the cached buffer object.
World-space unit globe-radial up at the camera, for hemispheric ambient shading. Up varies negligibly over shading-relevant distances, so one per-frame vector serves every lit drawable; eye-space consumers multiply by modelviewNormalTransform.
Functions
Specifies the OpenGL multitexture unit to make active. This has no effect if the specified multitexture unit is already active. The default is GL_TEXTURE0.
Binds the per-frame cascade depth textures to texture units 1..4 and pushes the cascade uniforms into program — or, when no shadow state is available (no earth.worldwind.layer.shadow.ShadowLayer this frame, or pick mode, or the platform can't run the depth-texture cascade pipeline, or the caller passes applyShadow = false), calls ShadowReceiverProgram.loadShadowDisabled so the receiver shader's applyShadow branch elides the lookup. Active texture unit is restored to GL_TEXTURE0 on the way out so subsequent texture binds in the caller's draw method land on the surface texture as expected.
Binds the sightline depth cube on unit 5 and uploads the sightline uniforms into program. Skips the work when there's no active sightline this frame (or in pick mode), and clears applySightline so receivers fall through to "no tint".
Makes an OpenGL buffer object bound to a specified target buffer. This has no effect if the specified buffer object is already bound. The default is buffer 0, indicating that no buffer object is bound.
Puts dynamic vertex data into the buffer pool and returns offset.
Makes an OpenGL framebuffer object active. The active framebuffer becomes the target of all OpenGL commands that render to the framebuffer or read from the framebuffer. This has no effect if the specified framebuffer object is already active. The default is framebuffer 0, indicating that the default framebuffer provided by the windowing system is active.
Makes an OpenGL texture 2D object bound to the current multitexture unit. This has no effect if the specified texture object is already bound. The default is texture 0, indicating that no texture is bound.
Returns the name of the OpenGL buffer object bound to the specified target buffer.
Returns the name of the OpenGL texture 2D object currently bound to the specified multitexture unit.
Reduced-resolution Gaussian-splat pass target: RGBA color (LINEAR, for the composite upsample) + 24-bit depth texture for the terrain occlusion prepass. Grows monotonically like the pick framebuffer; callers render into the lower-left width x height region and sample it back via a texture-scale uniform. Requires sized texture formats — callers gate on earth.worldwind.util.kgl.Kgl.supportsSizedTextureFormats and fall back to direct drawing otherwise. Returns null if the framebuffer cannot be completed.
Parks a benign cube on unit 5 and invalidates the sightline bind cache. Called by DrawableSightline whenever it clobbers unit 5 for feedback safety (a texture bound for sampling can't also be a render target). Without the lastSightlineTextureBind reset a later receiver holding the same SightlineState would cache-hit and sample this benign cube instead of the real depth cube - safe today only by drawable ordering. The parked cube is compare-mode (nullShadowDepthCubeTexture) under hardware samplers, matching the receiver path so WebGL2's draw-time sampler-vs-format validation stays consistent.
Reads the fragment color at a screen point in the currently active OpenGL frame buffer. The X and Y components indicate OpenGL screen coordinates, which originate in the frame buffer's lower left corner.
Reads fragment colors over a screen rectangle into a row-major list (no de-duplication), indexed row * width + col. Companion to readPixelDepths so colors and depths can be iterated in lockstep.
Single-pixel depth from the RGB-packed depth color attachment. See DepthToColorProgram.
Row-major 24-bit normalized depths over a screen rectangle, in [0, 1]. Reads from the RGB-packed depth color attachment; see DepthToColorProgram.
Returns a scratch NIO buffer suitable for use during drawing. The returned buffer has capacity at least equal to the specified capacity. The buffer is cleared before each frame, otherwise its contents, position, limit and mark are undefined.
Returns the per-cascade shadow framebuffer for the directional sun-shadow pipeline. Each cascade is depth-only: a GL_DEPTH_COMPONENT24 texture holds true hardware depth written by DirectionalDepthProgram's pass (which lets glPolygonOffset apply slope-scaled caster bias). On Kgl.hasShadowSamplers platforms the texture carries LINEAR + COMPARE_REF_TO_TEXTURE and receivers tap it through sampler2DShadow (hardware 2x2 PCF per tap); otherwise receivers read raw depth from the red channel, where GL_NEAREST is mandatory and the software percentage-closer filter does its own bilinear weighting across texels. Clamp-to-edge keeps out-of-footprint UVs from wrapping to the opposite side of the map. Lazily allocated and cached per cascade.
Forgets a deleted texture in the per-unit bind cache. GL auto-unbinds deleted names, so a recycled name would otherwise cache-hit here and skip the real bind on rarely-rebound units.
Makes an OpenGL program object active as part of current rendering state. This has no effect if the specified program object is already active. The default is program 0, indicating that no program is active.