Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nasaworldwind/worldwindjava/llms.txt
Use this file to discover all available pages before exploring further.
WorldWindow is the top-level interface common to all toolkit-specific WorldWind rendering surfaces. Every WorldWind application revolves around a WorldWindow instance — it owns the OpenGL context, drives the render loop, connects the Model (globe and layers) to the View (camera), and acts as the hub for all user interaction events. Applications never instantiate WorldWindow directly; instead they use one of the two concrete AWT/Swing implementations provided by the SDK.
Concrete Implementations
WorldWind ships two ready-to-useWorldWindow implementations that differ only in how they integrate with the Java UI toolkit:
| Class | Extends | Best For |
|---|---|---|
WorldWindowGLCanvas | com.jogamp.opengl.awt.GLCanvas (heavyweight AWT) | Most applications; best performance |
WorldWindowGLJPanel | com.jogamp.opengl.awt.GLJPanel (lightweight Swing) | Layouts that require a Swing component hierarchy |
WorldWindowGLCanvas is the preferred choice for new applications. It is a heavyweight AWT component backed by a native OpenGL surface. Because it is heavyweight, it follows the rules documented in the JOGL User’s Guide when mixed with lightweight Swing components — you may need to call ToolTipManager.setLightWeightPopupEnabled(false) and similar helpers.
Creating a WorldWindowGLCanvas and embedding it in a JFrame
Key Responsibilities
AWorldWindow coordinates four major concerns inside a single component:
- OpenGL context — manages JOGL’s
GLContextand the drawable lifecycle (init, display, reshape, dispose). - Render loop — delegates to a
SceneControllereach frame to tessellate the globe, sort and render layers, and perform picking. - Model and View — holds the active
Model(globe + layer list) and the activeView(camera position and orientation). - Event dispatch — fires
SelectEvent,PositionEvent, andRenderingEventnotifications to registered listeners.
The WorldWindow Interface
The following methods fromgov.nasa.worldwind.WorldWindow are the ones applications use most frequently:
WorldWindow interface — key method signatures
Event Listeners
Registering event listeners on a WorldWindow
Accessing WorldWind Services
TheWorldWind class is a singleton that owns the shared infrastructure services used across all WorldWindow instances in a JVM. You access it through static methods:
Accessing WorldWind singleton services
WorldWind class also exposes altitude-mode constants used throughout the rendering pipeline:
| Constant | Value | Meaning |
|---|---|---|
WorldWind.ABSOLUTE | 0 | Altitude is above mean sea level |
WorldWind.CLAMP_TO_GROUND | 1 | Object is clamped to the terrain surface |
WorldWind.RELATIVE_TO_GROUND | 2 | Altitude is relative to the terrain below |
WorldWind.CONSTANT | 3 | Altitude does not change with terrain |
GPU Resource Cache
EveryWorldWindow maintains a GpuResourceCache that stores GPU-resident objects — primarily textures and vertex buffer objects — so they are not re-uploaded to the graphics card every frame.
Querying the GPU resource cache
Applications should never modify the
GpuResourceCache directly for general rendering work. The cache is self-managed. Only implementations of custom shapes or layers that create their own GPU resources (textures, VBOs, display lists) should interact with it — and then only through the DrawContext that is passed to Layer.render() and Renderable.render(). Directly clearing or inserting items into the cache outside of a render call can cause excessive memory usage or application crashes.Threading
WorldWind’s rendering pipeline is not thread-safe. All modifications to the
Model, LayerList, or any Renderable should be made from the Event Dispatch Thread (EDT) or before the next call to redraw(). The render loop runs on the JOGL OpenGL thread; the EDT and the OpenGL thread are separate. Use SwingUtilities.invokeLater() to marshal changes from background threads back to the EDT before triggering a repaint with wwd.redraw().