Package panamagl.canvas
Class GLCanvasAWT
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
panamagl.canvas.GLCanvasAWT
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,panamagl.canvas.GLCanvas
This panel push to the screen an OpenGL image rendered offscreen by an
OffscreenRenderer.
The panel mainly deals with
- OpenGL context initialization, after the panel is added to a parent, and before it is made visible.
- repaint and resize events that are propagated to the OpenGL application through a
GLEventListener, which must be provided by the user of this panel throughsetGLEventListener(GLEventListener). - measuring performance, that is evaluating the time required to trigger offscreen image rendering and image painting onscreen.
Threading
The panel is also responsible for triggering OpenGL initialization and rendering in the appropriate threads, which may depend on the running operating system.Threading on macOS
Debugging
Hint : to debug this class, invoke a program using it with flag -Dpanamagl.GLPanel- Author:
- Martin Pernollet
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classTheGLCanvasAWT.ResizeHandlerwill trigger rendering on the main macOS thread and then trigger repaint through}.invalid @link
{@link SwingUtilities.invokeLater()Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanelNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyNested classes/interfaces inherited from interface panamagl.canvas.GLCanvas
panamagl.canvas.GLCanvas.Flip -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected panamagl.performance.RenderCounterprotected booleanprotected booleanprotected panamagl.canvas.GLCanvas.Flipprotected panamagl.GLEventListenerprotected panamagl.offscreen.OffscreenRendererprotected BufferedImageprotected PerformanceOverlay_AWTprotected AtomicBooleanFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionGLCanvasAWT(panamagl.factory.PanamaGLFactory factory) Initialize a panel able to render OpenGL through aGLEventListenerand relatedGLinterface. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after the JPanel has been added to the Swing hierarchy but before it is made visible.voiddisplay()If the panel initialization has achieved, this triggers an offscreen rendering, maybe on a separated thread (macOS case), from which an asynchronous repaint will be triggered.panamagl.opengl.GLContextpanamagl.offscreen.FBOgetFBO()panamagl.canvas.GLCanvas.FlipgetFlip()panamagl.opengl.GLgetGL()panamagl.GLEventListenerpanamagl.performance.RenderCounterpanamagl.offscreen.OffscreenRendererpanamagl.Image<?> booleanReturn true if the offscreen renderer has been initialized, which means that this panel has been added to a parent component.booleanReturn true if display has started but has not yet finishedprotected voidShow performance in a 2D text overlay.voidInvoked only for redraw query that are not coalesced with other redraw queries by the AWT Event Queue.voidCalled before the JPanel is removed from the Swing hierarchy.voidsetFBO(panamagl.offscreen.FBO fbo) voidsetFlip(panamagl.canvas.GLCanvas.Flip flip) voidsetGLEventListener(panamagl.GLEventListener glEvents) voidsetMonitoring(panamagl.performance.RenderCounter counter) voidsetOffscreenRenderer(panamagl.offscreen.OffscreenRenderer offscreen) protected voidsetRendering(boolean status) voidsetScreenshot(panamagl.Image<?> image) voidInvoked each time redraw should be performed, even if the redraw query is coalesced with other redraw queries by the AWT Event Queue.Methods inherited from class java.awt.Panel
getAccessibleContextMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface panamagl.canvas.GLCanvas
getHeight, getWidth, isVisible, repaint
-
Field Details
-
listener
protected panamagl.GLEventListener listener -
offscreen
protected panamagl.offscreen.OffscreenRenderer offscreen -
out
-
rendering
-
counter
protected panamagl.performance.RenderCounter counter -
overlay
-
debug
protected boolean debug -
debugPerf
protected boolean debugPerf -
flip
protected panamagl.canvas.GLCanvas.Flip flip
-
-
Constructor Details
-
GLCanvasAWT
public GLCanvasAWT(panamagl.factory.PanamaGLFactory factory) Initialize a panel able to render OpenGL through aGLEventListenerand relatedGLinterface.
-
-
Method Details
-
addNotify
public void addNotify()Called after the JPanel has been added to the Swing hierarchy but before it is made visible. Initialization may occur in other threads and not be completed when this method returns. To ensure the component is initialized, callinvalid reference
invalid input: '' -
removeNotify
public void removeNotify()Called before the JPanel is removed from the Swing hierarchy.- Overrides:
removeNotifyin classContainer
-
update
-
paint
-
display
public void display()If the panel initialization has achieved, this triggers an offscreen rendering, maybe on a separated thread (macOS case), from which an asynchronous repaint will be triggered.- Specified by:
displayin interfacepanamagl.canvas.GLCanvas
-
isInitialized
public boolean isInitialized()Return true if the offscreen renderer has been initialized, which means that this panel has been added to a parent component.- Specified by:
isInitializedin interfacepanamagl.canvas.GLCanvas
-
isRendering
public boolean isRendering()Return true if display has started but has not yet finished- Specified by:
isRenderingin interfacepanamagl.canvas.GLCanvas
-
setRendering
protected void setRendering(boolean status) -
overlayPerformance
Show performance in a 2D text overlay. -
getGLEventListener
public panamagl.GLEventListener getGLEventListener()- Specified by:
getGLEventListenerin interfacepanamagl.canvas.GLCanvas
-
setGLEventListener
public void setGLEventListener(panamagl.GLEventListener glEvents) - Specified by:
setGLEventListenerin interfacepanamagl.canvas.GLCanvas
-
getGL
public panamagl.opengl.GL getGL()- Specified by:
getGLin interfacepanamagl.canvas.GLCanvas
-
getContext
public panamagl.opengl.GLContext getContext()- Specified by:
getContextin interfacepanamagl.canvas.GLCanvas
-
getScreenshot
public panamagl.Image<?> getScreenshot()- Specified by:
getScreenshotin interfacepanamagl.canvas.GLCanvas
-
setScreenshot
public void setScreenshot(panamagl.Image<?> image) - Specified by:
setScreenshotin interfacepanamagl.canvas.GLCanvas
-
getFBO
public panamagl.offscreen.FBO getFBO() -
setFBO
public void setFBO(panamagl.offscreen.FBO fbo) -
getMonitoring
public panamagl.performance.RenderCounter getMonitoring()- Specified by:
getMonitoringin interfacepanamagl.canvas.GLCanvas
-
setMonitoring
public void setMonitoring(panamagl.performance.RenderCounter counter) -
getOffscreenRenderer
public panamagl.offscreen.OffscreenRenderer getOffscreenRenderer()- Specified by:
getOffscreenRendererin interfacepanamagl.canvas.GLCanvas
-
setOffscreenRenderer
public void setOffscreenRenderer(panamagl.offscreen.OffscreenRenderer offscreen) - Specified by:
setOffscreenRendererin interfacepanamagl.canvas.GLCanvas
-
setFlip
public void setFlip(panamagl.canvas.GLCanvas.Flip flip) - Specified by:
setFlipin interfacepanamagl.canvas.GLCanvas
-
getFlip
public panamagl.canvas.GLCanvas.Flip getFlip()- Specified by:
getFlipin interfacepanamagl.canvas.GLCanvas
-