Class AWTGLCanvas

    • Constructor Detail

      • 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 Detail

      • 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
      • setSwapInterval

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

        public void setVSyncEnabled​(boolean enabled)
        Enable vsync
      • 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
      • setLocation

        public void setLocation​(int x,
                                int y)
        Overrides:
        setLocation 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