Class AWTGLCanvas

All Implemented Interfaces:
ComponentListener, HierarchyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Drawable

public class AWTGLCanvas extends Canvas implements ComponentListener, HierarchyListener

An AWT rendering context.

Version:
$Revision$
Author:
$Author$ $Id$
See Also:
  • Constructor Details

    • AWTGLCanvas

      public AWTGLCanvas() throws LWJGLException
      Constructor 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(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException
      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 null
      drawable - 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 null
      drawable - The Drawable to share context with
      attribs - The ContextAttribs to use when creating the context. (optional, may be null)
      Throws:
      LWJGLException
  • Method Details

    • 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 LWJGLException
      This 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:
      addNotify in class Canvas
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class Component
    • setSwapInterval

      public void setSwapInterval(int swap_interval)
      Set swap interval.
    • setVSyncEnabled

      public void setVSyncEnabled(boolean enabled)
      Enable vsync
    • swapBuffers

      public void swapBuffers() throws LWJGLException
      Swap the canvas' buffer
      Throws:
      LWJGLException
    • isCurrent

      public boolean isCurrent() throws LWJGLException
      Description copied from interface: Drawable
      Returns true if the Drawable's context is current in the current thread.
      Specified by:
      isCurrent in interface Drawable
      Throws:
      LWJGLException
    • makeCurrent

      public void makeCurrent() throws LWJGLException
      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 interface Drawable
      Throws:
      LWJGLException
    • releaseContext

      public void releaseContext() throws LWJGLException
      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 interface Drawable
      Throws:
      LWJGLException
    • destroy

      public final void destroy()
      Destroy the OpenGL context. This happens when the component becomes undisplayable
      Specified by:
      destroy in interface Drawable
    • setCLSharingProperties

      public final void setCLSharingProperties(PointerBuffer properties) throws LWJGLException
      Description copied from interface: Drawable
      Sets the appropriate khr_gl_sharing properties in the target PointerBuffer, so that if it is used in a clCreateContext(FromType) call, the created CL context will be sharing objects with this Drawable'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 interface Drawable
      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(Graphics g)
      The default paint() operation makes the context current and calls paintGL() which should be overridden to do GL operations.
      Overrides:
      paint in class 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(Graphics g)
      override update to avoid clearing
      Overrides:
      update in class Canvas
    • componentShown

      public void componentShown(ComponentEvent e)
      Specified by:
      componentShown in interface ComponentListener
    • componentHidden

      public void componentHidden(ComponentEvent e)
      Specified by:
      componentHidden in interface ComponentListener
    • componentResized

      public void componentResized(ComponentEvent e)
      Specified by:
      componentResized in interface ComponentListener
    • componentMoved

      public void componentMoved(ComponentEvent e)
      Specified by:
      componentMoved in interface ComponentListener
    • setLocation

      public void setLocation(int x, int y)
      Overrides:
      setLocation in class Component
    • setLocation

      public void setLocation(Point p)
      Overrides:
      setLocation in class Component
    • setSize

      public void setSize(Dimension d)
      Overrides:
      setSize in class Component
    • setSize

      public void setSize(int width, int height)
      Overrides:
      setSize in class Component
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overrides:
      setBounds in class Component
    • hierarchyChanged

      public void hierarchyChanged(HierarchyEvent e)
      Specified by:
      hierarchyChanged in interface HierarchyListener