Class WorldWindowGLAutoDrawable
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.WorldWindowImpl
-
- gov.nasa.worldwind.WorldWindowGLAutoDrawable
-
- All Implemented Interfaces:
com.jogamp.opengl.GLEventListener
,AVList
,MessageListener
,WorldWindow
,WorldWindowGLDrawable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
ConfiguringGLRuntimeCapabilities.MyGLAutoDrawable
,DebuggingGLErrors.MyGLAutoDrawable
public class WorldWindowGLAutoDrawable extends WorldWindowImpl implements WorldWindowGLDrawable, com.jogamp.opengl.GLEventListener
A non-platform specificWorldWindow
class. This class can be aggregated into platform-specific classes to provide the core functionality of WorldWind.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_VIEW_STOP_TIME
Default time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPED
message is sent.protected boolean
enableGpuCacheReinitialization
protected long
lastViewID
The most recent View modelView ID.protected java.util.concurrent.ScheduledFuture
viewRefreshTask
Schedule task to send theView.VIEW_STOPPED
message after the view stop time elapses.protected long
viewStopTime
Time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPED
message is sent.-
Fields inherited from class gov.nasa.worldwind.WorldWindowImpl
gpuResourceCache
-
-
Constructor Summary
Constructors Constructor Description WorldWindowGLAutoDrawable()
Construct a newWorldWindowGLCanvas
for a specifiedGLDrawable
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkForViewChange()
Determine if the view has changed since the previous frame.void
display(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.display(GLAutoDrawable)
.void
dispose(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.init(GLAutoDrawable)
.protected int
doDisplay()
Performs the actual repaint.protected void
doShutdown()
protected void
doSwapBuffers(com.jogamp.opengl.GLAutoDrawable drawable)
Performs the actual buffer swap.void
endInitialization()
com.jogamp.opengl.GLContext
getContext()
Returns theGLContext
associated with thisWorldWindow
.protected java.lang.String[]
getRequiredOglExtensions()
protected java.lang.String[]
getRequiredOglFunctions()
long
getViewStopTime()
Indicates the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPED
event is triggered.void
init(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.init(GLAutoDrawable)
.void
initDrawable(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
void
initGpuResourceCache(GpuResourceCache cache)
protected void
initializeCreditsController()
boolean
isEnableGpuCacheReinitialization()
Indicates whether the GPU resource cache is reinitialized when this window is reinitialized.protected boolean
isGLContextCompatible(com.jogamp.opengl.GLContext context)
void
onMessage(Message msg)
Empty implementation of MessageListener.void
propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
The property change listener for this instance.void
redraw()
Causes a repaint event to be enqueued with the window system for this WorldWindow.void
redrawNow()
Immediately repaints the WorldWindow without waiting for a window system repaint event.protected void
reinitialize(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
void
reshape(com.jogamp.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int w, int h)
SeeGLEventListener.reshape(GLAutoDrawable, int, int, int, int)
.protected void
scheduleViewStopTask(long delay)
Schedule a task that will send aView.VIEW_STOPPED
message to the Model when the task executes.void
setEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)
Specifies whether to reinitialize the GPU resource cache when this window is reinitialized.void
setViewStopTime(long time)
Specifies the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPED
event is triggered.void
shutdown()
Causes resources used by the WorldWindow to be freed.-
Methods inherited from class gov.nasa.worldwind.WorldWindowImpl
addPositionListener, addRenderingExceptionListener, addRenderingListener, addSelectListener, callPositionListeners, callRenderingExceptionListeners, callRenderingListeners, callSelectListeners, configureIdentityPixelScale, createGpuResourceCache, getCurrentBoxSelection, getCurrentPosition, getCurrentSelection, getGpuResourceCache, getInputHandler, getModel, getObjectsAtCurrentPosition, getObjectsInSelectionBox, getPerFrameStatistics, getSceneController, getView, removePositionListener, removeRenderingExceptionListener, removeRenderingListener, removeSelectListener, setGpuResourceCache, setInputHandler, setModel, setModelAndView, setPerFrameStatisticsKeys, setSceneController, setView
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.WorldWindow
addPositionListener, addRenderingExceptionListener, addRenderingListener, addSelectListener, getCurrentPosition, getGpuResourceCache, getInputHandler, getModel, getObjectsAtCurrentPosition, getObjectsInSelectionBox, getPerFrameStatistics, getSceneController, getView, removePositionListener, removeRenderingExceptionListener, removeRenderingListener, removeSelectListener, setInputHandler, setModel, setModelAndView, setPerFrameStatisticsKeys, setSceneController, setView
-
-
-
-
Field Detail
-
DEFAULT_VIEW_STOP_TIME
public static final long DEFAULT_VIEW_STOP_TIME
Default time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPED
message is sent.- See Also:
- Constant Field Values
-
viewStopTime
protected long viewStopTime
Time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPED
message is sent.
-
lastViewID
protected long lastViewID
The most recent View modelView ID.- See Also:
View.getViewStateID()
-
viewRefreshTask
protected java.util.concurrent.ScheduledFuture viewRefreshTask
Schedule task to send theView.VIEW_STOPPED
message after the view stop time elapses.
-
enableGpuCacheReinitialization
protected boolean enableGpuCacheReinitialization
-
-
Method Detail
-
getViewStopTime
public long getViewStopTime()
Indicates the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPED
event is triggered.- Returns:
- Time in milliseconds that the View must must remain unchanged before the view stopped event is triggered.
-
setViewStopTime
public void setViewStopTime(long time)
Specifies the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPED
event is triggered.- Parameters:
time
- Time in milliseconds that the View must must remain unchanged before the view stopped event is triggered.
-
initDrawable
public void initDrawable(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
- Specified by:
initDrawable
in interfaceWorldWindowGLDrawable
-
isEnableGpuCacheReinitialization
public boolean isEnableGpuCacheReinitialization()
Description copied from interface:WorldWindow
Indicates whether the GPU resource cache is reinitialized when this window is reinitialized.- Specified by:
isEnableGpuCacheReinitialization
in interfaceWorldWindow
- Returns:
true
if reinitialization is enabled, otherwisefalse
.
-
setEnableGpuCacheReinitialization
public void setEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)
Description copied from interface:WorldWindow
Specifies whether to reinitialize the GPU resource cache when this window is reinitialized. A value oftrue
indicates that the GPU resource cache this window is using should be cleared when its init() method is called, typically when re-parented. Set this tofalse
when this window is sharing context with other windows and is likely to be re-parented. It prevents the flashing caused by clearing and re-populating the GPU resource cache during re-parenting. The default value istrue
.- Specified by:
setEnableGpuCacheReinitialization
in interfaceWorldWindow
- Parameters:
enableGpuCacheReinitialization
-true
to enable reinitialization, otherwisefalse
.
-
initGpuResourceCache
public void initGpuResourceCache(GpuResourceCache cache)
- Specified by:
initGpuResourceCache
in interfaceWorldWindowGLDrawable
-
endInitialization
public void endInitialization()
- Specified by:
endInitialization
in interfaceWorldWindowGLDrawable
-
initializeCreditsController
protected void initializeCreditsController()
-
shutdown
public void shutdown()
Description copied from class:WorldWindowImpl
Causes resources used by the WorldWindow to be freed. The WorldWindow cannot be used once this method is called. An OpenGL context for the window must be current.- Specified by:
shutdown
in interfaceWorldWindow
- Overrides:
shutdown
in classWorldWindowImpl
-
doShutdown
protected void doShutdown()
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Description copied from class:WWObjectImpl
The property change listener for this instance. Receives property change notifications that this instance has registered with other property change notifiers.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Overrides:
propertyChange
in classWWObjectImpl
- Parameters:
propertyChangeEvent
- the event
-
getContext
public com.jogamp.opengl.GLContext getContext()
Description copied from interface:WorldWindow
Returns theGLContext
associated with thisWorldWindow
.- Specified by:
getContext
in interfaceWorldWindow
- Returns:
- the
GLContext
associated with this window. May be null.
-
isGLContextCompatible
protected boolean isGLContextCompatible(com.jogamp.opengl.GLContext context)
-
getRequiredOglFunctions
protected java.lang.String[] getRequiredOglFunctions()
-
getRequiredOglExtensions
protected java.lang.String[] getRequiredOglExtensions()
-
init
public void init(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.init(GLAutoDrawable)
.- Specified by:
init
in interfacecom.jogamp.opengl.GLEventListener
- Parameters:
glAutoDrawable
- the drawable
-
reinitialize
protected void reinitialize(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
-
dispose
public void dispose(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.init(GLAutoDrawable)
.GLEventListener's dispose method indicates that the GL context has been released, and provides the listener an opportunity to clean up any resources. Dispose does not imply that the component's lifecycle has ended or that the application is closing. There are three cases in which dispose may be called:
- The WorldWindow is removed from its parent component.
- The WorldWindow's parent frame is closed.
- The application calls either GLCanvas.dispose or GLJPanel.dispose.
This implementation is left empty. In the case when a WorldWindow or a WorldWind application has reached its end of life, its resources should be released by calling
WorldWindow.shutdown()
orWorldWind.shutDown()
, respectively. In the case when a WorldWindow is removed from its parent frame or that frame is closed without a call to shutdown, it is assumed that the application intends to reuse the WorldWindow. Resources associated with the previous GL context are released in the subsequent call to init.- Specified by:
dispose
in interfacecom.jogamp.opengl.GLEventListener
- Parameters:
glAutoDrawable
- the drawable
-
display
public void display(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.display(GLAutoDrawable)
.- Specified by:
display
in interfacecom.jogamp.opengl.GLEventListener
- Parameters:
glAutoDrawable
- the drawable- Throws:
java.lang.IllegalStateException
- if noSceneController
exists for this canvas
-
checkForViewChange
protected void checkForViewChange()
Determine if the view has changed since the previous frame. If the view has changed, schedule a task that will send aView.VIEW_STOPPED
to the Model if the view does not change forviewStopTime
milliseconds.- See Also:
getViewStopTime()
-
doDisplay
protected int doDisplay()
Performs the actual repaint. Provided so that subclasses may override the repaint steps.- Returns:
- if greater than zero, the window should be automatically repainted again at the indicated number of milliseconds from this method's return.
-
doSwapBuffers
protected void doSwapBuffers(com.jogamp.opengl.GLAutoDrawable drawable)
Performs the actual buffer swap. Provided so that subclasses may override the swap steps.- Parameters:
drawable
- the window's associated drawable.
-
reshape
public void reshape(com.jogamp.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int w, int h)
SeeGLEventListener.reshape(GLAutoDrawable, int, int, int, int)
.- Specified by:
reshape
in interfacecom.jogamp.opengl.GLEventListener
- Parameters:
glAutoDrawable
- the drawable
-
redraw
public void redraw()
Description copied from interface:WorldWindow
Causes a repaint event to be enqueued with the window system for this WorldWindow. The repaint will occur at the window system's discretion, within the window system toolkit's event loop, and on the thread of that loop. This is the preferred method for requesting a repaint of the WorldWindow.- Specified by:
redraw
in interfaceWorldWindow
- Overrides:
redraw
in classWorldWindowImpl
-
redrawNow
public void redrawNow()
Description copied from interface:WorldWindow
Immediately repaints the WorldWindow without waiting for a window system repaint event. This is not the preferred way to cause a repaint, but is provided for the rare cases that require it.- Specified by:
redrawNow
in interfaceWorldWindow
- Overrides:
redrawNow
in classWorldWindowImpl
-
scheduleViewStopTask
protected void scheduleViewStopTask(long delay)
Schedule a task that will send aView.VIEW_STOPPED
message to the Model when the task executes. If the task runs (is not cancelled), then the view is considered stopped. Only one view stop task is scheduled at a time. If this method is called again before the task executes, the task will be cancelled and a new task scheduled.- Parameters:
delay
- Delay in milliseconds until the task runs.
-
onMessage
public void onMessage(Message msg)
Empty implementation of MessageListener.Forward the message event to the Model for distribution to the layers.
- Specified by:
onMessage
in interfaceMessageListener
- Overrides:
onMessage
in classWWObjectImpl
- Parameters:
msg
- Message event.
-
-