Package org.lwjgl.opengl
Class AWTGLCanvas
java.lang.Object
java.awt.Component
java.awt.Canvas
org.lwjgl.opengl.AWTGLCanvas
- All Implemented Interfaces:
ComponentListener
,HierarchyListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,Drawable
An AWT rendering context.
- Version:
- $Revision$
- Author:
- $Author$ $Id$
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvas
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor using the default PixelFormat.AWTGLCanvas
(GraphicsDevice device, PixelFormat pixel_format) Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice.AWTGLCanvas
(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice.AWTGLCanvas
(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
Modifier and TypeMethodDescriptionvoid
void
void
void
void
void
org.lwjgl.opengl.ContextGL
This method should only be called internally.final void
destroy()
Destroy the OpenGL context.protected void
exceptionOccurred
(LWJGLException exception) This method will be called if an unhandled LWJGLException occurs in paint().org.lwjgl.opengl.ContextGL
This method should only be called internally.void
void
initContext
(float r, float g, float b) protected void
initGL()
Override this to do initialising of the context.boolean
Returns true if the Drawable's context is current in the current thread.void
Make the canvas' context current.final void
The default paint() operation makes the context current and calls paintGL() which should be overridden to do GL operations.protected void
paintGL()
Override this to do paintingvoid
If the Drawable's context is current in the current thread, no context will be current after a call to this method.void
void
setBounds
(int x, int y, int width, int height) final void
setCLSharingProperties
(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.void
setLocation
(int x, int y) void
setLocation
(Point p) void
void
setPixelFormat
(PixelFormatLWJGL pf, ContextAttribs attribs) void
setSize
(int width, int height) void
void
setSwapInterval
(int swap_interval) Set swap interval.void
setVSyncEnabled
(boolean enabled) Enable vsyncvoid
Swap the canvas' buffervoid
override update to avoid clearingMethods 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 Details
-
AWTGLCanvas
Constructor using the default PixelFormat.- Throws:
LWJGLException
-
AWTGLCanvas
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
Create 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(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException Create 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(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLException Create 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 Details
-
setPixelFormat
- Throws:
LWJGLException
-
setPixelFormat
- Throws:
LWJGLException
-
getPixelFormat
-
getContext
public org.lwjgl.opengl.ContextGL getContext()This method should only be called internally. -
checkGLError
public void checkGLError() -
initContext
public void initContext(float r, float g, float b) -
addNotify
public void addNotify() -
removeNotify
public void removeNotify()- Overrides:
removeNotify
in classComponent
-
setSwapInterval
public void setSwapInterval(int swap_interval) Set swap interval. -
setVSyncEnabled
public void setVSyncEnabled(boolean enabled) Enable vsync -
swapBuffers
Swap the canvas' buffer- Throws:
LWJGLException
-
isCurrent
Description copied from interface:Drawable
Returns true if the Drawable's context is current in the current thread.- Specified by:
isCurrent
in interfaceDrawable
- Throws:
LWJGLException
-
makeCurrent
Make 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:
makeCurrent
in interfaceDrawable
- Throws:
LWJGLException
-
releaseContext
Description copied from interface:Drawable
If the Drawable's context is current in the current thread, no context will be current after a call to this method.- Specified by:
releaseContext
in interfaceDrawable
- Throws:
LWJGLException
-
destroy
public final void destroy()Destroy the OpenGL context. This happens when the component becomes undisplayable -
setCLSharingProperties
Description copied from interface:Drawable
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. After a call to this method, the target buffer position will have advanced by 2 to 4 positions, depending on the implementation.- Specified by:
setCLSharingProperties
in 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
The default paint() operation makes the context current and calls paintGL() which should be overridden to do GL operations. -
exceptionOccurred
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
override update to avoid clearing -
componentShown
- Specified by:
componentShown
in interfaceComponentListener
-
componentHidden
- Specified by:
componentHidden
in interfaceComponentListener
-
componentResized
- Specified by:
componentResized
in interfaceComponentListener
-
componentMoved
- Specified by:
componentMoved
in interfaceComponentListener
-
setLocation
public void setLocation(int x, int y) - Overrides:
setLocation
in classComponent
-
setLocation
- Overrides:
setLocation
in classComponent
-
setSize
-
setSize
public void setSize(int width, int height) -
setBounds
public void setBounds(int x, int y, int width, int height) -
hierarchyChanged
- Specified by:
hierarchyChanged
in interfaceHierarchyListener
-