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 specificWorldWindowclass. 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 longDEFAULT_VIEW_STOP_TIMEDefault time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPEDmessage is sent.protected booleanenableGpuCacheReinitializationprotected longlastViewIDThe most recent View modelView ID.protected java.util.concurrent.ScheduledFutureviewRefreshTaskSchedule task to send theView.VIEW_STOPPEDmessage after the view stop time elapses.protected longviewStopTimeTime in milliseconds that the view must remain unchanged before theView.VIEW_STOPPEDmessage is sent.-
Fields inherited from class gov.nasa.worldwind.WorldWindowImpl
gpuResourceCache
-
-
Constructor Summary
Constructors Constructor Description WorldWindowGLAutoDrawable()Construct a newWorldWindowGLCanvasfor a specifiedGLDrawable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckForViewChange()Determine if the view has changed since the previous frame.voiddisplay(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)SeeGLEventListener.display(GLAutoDrawable).voiddispose(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)SeeGLEventListener.init(GLAutoDrawable).protected intdoDisplay()Performs the actual repaint.protected voiddoShutdown()protected voiddoSwapBuffers(com.jogamp.opengl.GLAutoDrawable drawable)Performs the actual buffer swap.voidendInitialization()com.jogamp.opengl.GLContextgetContext()Returns theGLContextassociated with thisWorldWindow.protected java.lang.String[]getRequiredOglExtensions()protected java.lang.String[]getRequiredOglFunctions()longgetViewStopTime()Indicates the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPEDevent is triggered.voidinit(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)SeeGLEventListener.init(GLAutoDrawable).voidinitDrawable(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)voidinitGpuResourceCache(GpuResourceCache cache)protected voidinitializeCreditsController()booleanisEnableGpuCacheReinitialization()Indicates whether the GPU resource cache is reinitialized when this window is reinitialized.protected booleanisGLContextCompatible(com.jogamp.opengl.GLContext context)voidonMessage(Message msg)Empty implementation of MessageListener.voidpropertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)The property change listener for this instance.voidredraw()Causes a repaint event to be enqueued with the window system for this WorldWindow.voidredrawNow()Immediately repaints the WorldWindow without waiting for a window system repaint event.protected voidreinitialize(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)voidreshape(com.jogamp.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int w, int h)SeeGLEventListener.reshape(GLAutoDrawable, int, int, int, int).protected voidscheduleViewStopTask(long delay)Schedule a task that will send aView.VIEW_STOPPEDmessage to the Model when the task executes.voidsetEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)Specifies whether to reinitialize the GPU resource cache when this window is reinitialized.voidsetViewStopTime(long time)Specifies the amount of time, in milliseconds, that the View must remain unchanged before aView.VIEW_STOPPEDevent is triggered.voidshutdown()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_STOPPEDmessage is sent.- See Also:
- Constant Field Values
-
viewStopTime
protected long viewStopTime
Time in milliseconds that the view must remain unchanged before theView.VIEW_STOPPEDmessage 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_STOPPEDmessage 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_STOPPEDevent 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_STOPPEDevent 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:
initDrawablein interfaceWorldWindowGLDrawable
-
isEnableGpuCacheReinitialization
public boolean isEnableGpuCacheReinitialization()
Description copied from interface:WorldWindowIndicates whether the GPU resource cache is reinitialized when this window is reinitialized.- Specified by:
isEnableGpuCacheReinitializationin interfaceWorldWindow- Returns:
trueif reinitialization is enabled, otherwisefalse.
-
setEnableGpuCacheReinitialization
public void setEnableGpuCacheReinitialization(boolean enableGpuCacheReinitialization)
Description copied from interface:WorldWindowSpecifies whether to reinitialize the GPU resource cache when this window is reinitialized. A value oftrueindicates that the GPU resource cache this window is using should be cleared when its init() method is called, typically when re-parented. Set this tofalsewhen 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:
setEnableGpuCacheReinitializationin interfaceWorldWindow- Parameters:
enableGpuCacheReinitialization-trueto enable reinitialization, otherwisefalse.
-
initGpuResourceCache
public void initGpuResourceCache(GpuResourceCache cache)
- Specified by:
initGpuResourceCachein interfaceWorldWindowGLDrawable
-
endInitialization
public void endInitialization()
- Specified by:
endInitializationin interfaceWorldWindowGLDrawable
-
initializeCreditsController
protected void initializeCreditsController()
-
shutdown
public void shutdown()
Description copied from class:WorldWindowImplCauses 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:
shutdownin interfaceWorldWindow- Overrides:
shutdownin classWorldWindowImpl
-
doShutdown
protected void doShutdown()
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Description copied from class:WWObjectImplThe property change listener for this instance. Receives property change notifications that this instance has registered with other property change notifiers.- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein classWWObjectImpl- Parameters:
propertyChangeEvent- the event
-
getContext
public com.jogamp.opengl.GLContext getContext()
Description copied from interface:WorldWindowReturns theGLContextassociated with thisWorldWindow.- Specified by:
getContextin interfaceWorldWindow- Returns:
- the
GLContextassociated 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:
initin 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:
disposein interfacecom.jogamp.opengl.GLEventListener- Parameters:
glAutoDrawable- the drawable
-
display
public void display(com.jogamp.opengl.GLAutoDrawable glAutoDrawable)
SeeGLEventListener.display(GLAutoDrawable).- Specified by:
displayin interfacecom.jogamp.opengl.GLEventListener- Parameters:
glAutoDrawable- the drawable- Throws:
java.lang.IllegalStateException- if noSceneControllerexists 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_STOPPEDto the Model if the view does not change forviewStopTimemilliseconds.- 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:
reshapein interfacecom.jogamp.opengl.GLEventListener- Parameters:
glAutoDrawable- the drawable
-
redraw
public void redraw()
Description copied from interface:WorldWindowCauses 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:
redrawin interfaceWorldWindow- Overrides:
redrawin classWorldWindowImpl
-
redrawNow
public void redrawNow()
Description copied from interface:WorldWindowImmediately 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:
redrawNowin interfaceWorldWindow- Overrides:
redrawNowin classWorldWindowImpl
-
scheduleViewStopTask
protected void scheduleViewStopTask(long delay)
Schedule a task that will send aView.VIEW_STOPPEDmessage 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:
onMessagein interfaceMessageListener- Overrides:
onMessagein classWWObjectImpl- Parameters:
msg- Message event.
-
-