Package org.lwjgl.opengl
Class AWTGLCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Canvas
-
- org.lwjgl.opengl.AWTGLCanvas
-
- All Implemented Interfaces:
java.awt.event.ComponentListener,java.awt.event.HierarchyListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,Drawable
public class AWTGLCanvas extends java.awt.Canvas implements java.awt.event.ComponentListener, java.awt.event.HierarchyListenerAn AWT rendering context.- Version:
- $Revision$
- Author:
- $Author$ $Id$
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AWTGLCanvas()Constructor using the default PixelFormat.AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format)Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format, Drawable drawable)Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs)Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.AWTGLCanvas(PixelFormat pixel_format)Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotify()voidcheckGLError()voidcomponentHidden(java.awt.event.ComponentEvent e)voidcomponentMoved(java.awt.event.ComponentEvent e)voidcomponentResized(java.awt.event.ComponentEvent e)voidcomponentShown(java.awt.event.ComponentEvent e)org.lwjgl.opengl.ContextGLcreateSharedContext()This method should only be called internally.voiddestroy()Destroy the OpenGL context.protected voidexceptionOccurred(LWJGLException exception)This method will be called if an unhandled LWJGLException occurs in paint().org.lwjgl.opengl.ContextGLgetContext()This method should only be called internally.PixelFormatLWJGLgetPixelFormat()voidhierarchyChanged(java.awt.event.HierarchyEvent e)voidinitContext(float r, float g, float b)protected voidinitGL()Override this to do initialising of the context.booleanisCurrent()Returns true if the Drawable's context is current in the current thread.voidmakeCurrent()Make the canvas' context current.voidpaint(java.awt.Graphics g)The default paint() operation makes the context current and calls paintGL() which should be overridden to do GL operations.protected voidpaintGL()Override this to do paintingvoidreleaseContext()If the Drawable's context is current in the current thread, no context will be current after a call to this method.voidremoveNotify()voidsetBounds(int x, int y, int width, int height)voidsetCLSharingProperties(PointerBuffer properties)Sets the appropriate khr_gl_sharing properties in the targetPointerBuffer, so that if it is used in aclCreateContext(FromType)call, the created CL context will be sharing objects with thisDrawable's GL context.voidsetLocation(int x, int y)voidsetLocation(java.awt.Point p)voidsetPixelFormat(PixelFormatLWJGL pf)voidsetPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs)voidsetSize(int width, int height)voidsetSize(java.awt.Dimension d)voidsetSwapInterval(int swap_interval)Set swap interval.voidsetVSyncEnabled(boolean enabled)Enable vsyncvoidswapBuffers()Swap the canvas' buffervoidupdate(java.awt.Graphics g)override update to avoid clearing-
Methods inherited from class java.awt.Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, 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, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
-
-
-
Constructor Detail
-
AWTGLCanvas
public AWTGLCanvas() throws LWJGLExceptionConstructor using the default PixelFormat.- Throws:
LWJGLException
-
AWTGLCanvas
public AWTGLCanvas(PixelFormat pixel_format) throws LWJGLException
Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.- Parameters:
pixel_format- The desired pixel format. May not be null- Throws:
LWJGLException
-
AWTGLCanvas
public AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format) throws LWJGLExceptionCreate an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.- Parameters:
device- the device to create the canvas on.pixel_format- The desired pixel format. May not be null- Throws:
LWJGLException
-
AWTGLCanvas
public AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLExceptionCreate an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.- Parameters:
device- the device to create the canvas on.pixel_format- The desired pixel format. May not be nulldrawable- The Drawable to share context with- Throws:
LWJGLException
-
AWTGLCanvas
public AWTGLCanvas(java.awt.GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLExceptionCreate an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.- Parameters:
device- the device to create the canvas on.pixel_format- The desired pixel format. May not be nulldrawable- The Drawable to share context withattribs- The ContextAttribs to use when creating the context. (optional, may be null)- Throws:
LWJGLException
-
-
Method Detail
-
setPixelFormat
public void setPixelFormat(PixelFormatLWJGL pf) throws LWJGLException
- Throws:
LWJGLException
-
setPixelFormat
public void setPixelFormat(PixelFormatLWJGL pf, ContextAttribs attribs) throws LWJGLException
- Throws:
LWJGLException
-
getPixelFormat
public PixelFormatLWJGL getPixelFormat()
-
getContext
public org.lwjgl.opengl.ContextGL getContext()
This method should only be called internally.
-
createSharedContext
public org.lwjgl.opengl.ContextGL createSharedContext() throws LWJGLExceptionThis method should only be called internally.- Throws:
LWJGLException
-
checkGLError
public void checkGLError()
-
initContext
public void initContext(float r, float g, float b)
-
addNotify
public void addNotify()
- Overrides:
addNotifyin classjava.awt.Canvas
-
removeNotify
public void removeNotify()
- Overrides:
removeNotifyin classjava.awt.Component
-
setSwapInterval
public void setSwapInterval(int swap_interval)
Set swap interval.
-
setVSyncEnabled
public void setVSyncEnabled(boolean enabled)
Enable vsync
-
swapBuffers
public void swapBuffers() throws LWJGLExceptionSwap the canvas' buffer- Throws:
LWJGLException
-
isCurrent
public boolean isCurrent() throws LWJGLExceptionDescription copied from interface:DrawableReturns true if the Drawable's context is current in the current thread.- Specified by:
isCurrentin interfaceDrawable- Throws:
LWJGLException
-
makeCurrent
public void makeCurrent() throws LWJGLExceptionMake the canvas' context current. It is highly recommended that the context is only made current inside the AWT thread (for example in an overridden paintGL()).- Specified by:
makeCurrentin interfaceDrawable- Throws:
LWJGLException
-
releaseContext
public void releaseContext() throws LWJGLExceptionDescription copied from interface:DrawableIf the Drawable's context is current in the current thread, no context will be current after a call to this method.- Specified by:
releaseContextin interfaceDrawable- Throws:
LWJGLException
-
destroy
public final void destroy()
Destroy the OpenGL context. This happens when the component becomes undisplayable
-
setCLSharingProperties
public final void setCLSharingProperties(PointerBuffer properties) throws LWJGLException
Description copied from interface:DrawableSets the appropriate khr_gl_sharing properties in the targetPointerBuffer, so that if it is used in aclCreateContext(FromType)call, the created CL context will be sharing objects with thisDrawable's GL context. After a call to this method, the target buffer position will have advanced by 2 to 4 positions, depending on the implementation.- Specified by:
setCLSharingPropertiesin interfaceDrawable- Parameters:
properties- The target properties buffer. It must have at least 4 positions remaining.- Throws:
LWJGLException
-
initGL
protected void initGL()
Override this to do initialising of the context. It will be called once from paint(), immediately after the context is created and made current.
-
paintGL
protected void paintGL()
Override this to do painting
-
paint
public final void paint(java.awt.Graphics g)
The default paint() operation makes the context current and calls paintGL() which should be overridden to do GL operations.- Overrides:
paintin classjava.awt.Canvas
-
exceptionOccurred
protected void exceptionOccurred(LWJGLException exception)
This method will be called if an unhandled LWJGLException occurs in paint(). Override this method to be notified of this.- Parameters:
exception- The exception that occurred.
-
update
public void update(java.awt.Graphics g)
override update to avoid clearing- Overrides:
updatein classjava.awt.Canvas
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShownin interfacejava.awt.event.ComponentListener
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHiddenin interfacejava.awt.event.ComponentListener
-
componentResized
public void componentResized(java.awt.event.ComponentEvent e)
- Specified by:
componentResizedin interfacejava.awt.event.ComponentListener
-
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)
- Specified by:
componentMovedin interfacejava.awt.event.ComponentListener
-
setLocation
public void setLocation(int x, int y)- Overrides:
setLocationin classjava.awt.Component
-
setLocation
public void setLocation(java.awt.Point p)
- Overrides:
setLocationin classjava.awt.Component
-
setSize
public void setSize(java.awt.Dimension d)
- Overrides:
setSizein classjava.awt.Component
-
setSize
public void setSize(int width, int height)- Overrides:
setSizein classjava.awt.Component
-
setBounds
public void setBounds(int x, int y, int width, int height)- Overrides:
setBoundsin classjava.awt.Component
-
hierarchyChanged
public void hierarchyChanged(java.awt.event.HierarchyEvent e)
- Specified by:
hierarchyChangedin interfacejava.awt.event.HierarchyListener
-
-