javax.media.opengl

## Interface GLEventListener

- All Superinterfaces:
    EventListener
  All Known Subinterfaces:
    CustomGLEventListener, StereoGLEventListener
  All Known Implementing Classes:
    JOGLNewtAppletBase, StereoClientRenderer

      public interface GLEventListener
      extends EventListener

  Declares events which client code can use to manage OpenGL rendering into a `GLAutoDrawable`. At the time any of these methods is called, the drawable has made its associated OpenGL context current, so it is valid to make OpenGL calls.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `display(GLAutoDrawable drawable)` Called by the drawable to initiate OpenGL rendering by the client.
    `void` | `dispose(GLAutoDrawable drawable)` Notifies the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL programs.
    `void` | `init(GLAutoDrawable drawable)` Called by the drawable immediately after the OpenGL context is initialized.
    `void` | `reshape(GLAutoDrawable drawable, int x, int y, int width, int height)` Called by the drawable during the first repaint after the component has been resized.

- - ### Method Detail

    - #### init

          void init(GLAutoDrawable drawable)

      Called by the drawable immediately after the OpenGL context is initialized. Can be used to perform one-time OpenGL initialization per GLContext, such as setup of lights and display lists.

      Note that this method may be called more than once if the underlying OpenGL context for the GLAutoDrawable is destroyed and recreated, for example if a GLCanvas is removed from the widget hierarchy and later added again.

    - #### dispose

          void dispose(GLAutoDrawable drawable)

      Notifies the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL programs.

      Called by the drawable before the OpenGL context is destroyed by an external event, like a reconfiguration of the `GLAutoDrawable` closing an attached window, but also manually by calling `destroy`.

      Note that this event does not imply the end of life of the application. It could be produced with a followup call to `init(GLAutoDrawable)` in case the GLContext has been recreated, e.g. due to a pixel configuration change in a multihead environment.

    - #### display

          void display(GLAutoDrawable drawable)

      Called by the drawable to initiate OpenGL rendering by the client. After all GLEventListeners have been notified of a display event, the drawable will swap its buffers if `setAutoSwapBufferMode` is enabled.

    - #### reshape

          void reshape(GLAutoDrawable drawable,
                     int x,
                     int y,
                     int width,
                     int height)

      Called by the drawable during the first repaint after the component has been resized.

      The client can update it's viewport associated data and view volume of the window appropriately.

      For efficiency the GL viewport has already been updated via `glViewport(x, y, width, height)` when this method is called.

      Parameters:
        `drawable` - the triggering `GLAutoDrawable`
        `x` - viewport x-coord in pixel units
        `y` - viewport y-coord in pixel units
        `width` - viewport width in pixel units
        `height` - viewport height in pixel units

Copyright 2010 JogAmp Community.