## javax.media.opengl
Interface GLDrawable

All Known Subinterfaces:
  GLAutoDrawable, GLPbuffer

All Known Implementing Classes:
  GLCanvas, GLJPanel

    public interface GLDrawable

An abstraction for an OpenGL rendering target. A GLDrawable's primary functionality is to create OpenGL contexts which can be used to perform rendering. A GLDrawable does not automatically create an OpenGL context, but all implementations of `GLAutoDrawable` do so upon creation.

Method Summary
`GLContext` `createContext(GLContext shareWith)` Creates a new context for drawing to this drawable that will optionally share display lists and other server-side OpenGL objects with the specified GLContext.
`GLCapabilities` `getChosenGLCapabilities()` Fetches the `GLCapabilities` corresponding to the chosen OpenGL capabilities (pixel format / visual) for this drawable.
`int` `getHeight()` Returns the current height of this GLDrawable.
`int` `getWidth()` Returns the current width of this GLDrawable.
`void` `setRealized(boolean realized)` Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into.
`void` `setSize(int width, int height)` Requests a new width and height for this GLDrawable.
`void` `swapBuffers()` Swaps the front and back buffers of this drawable.

Method Detail

### createContext

    GLContext createContext(GLContext shareWith)

  Creates a new context for drawing to this drawable that will optionally share display lists and other server-side OpenGL objects with the specified GLContext.

  The GLContext `share` need not be associated with this GLDrawable and may be null if sharing of display lists and other objects is not desired. See the note in the overview documentation on context sharing.

### setRealized

    void setRealized(boolean realized)

  Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into. This method must be called from GLDrawables obtained from the GLDrawableFactory via the `GLDrawableFactory.getGLDrawable()` method. It must typically be called with an argument of `true` in the `addNotify` method of components performing OpenGL rendering and with an argument of `false` in the `removeNotify` method. Calling this method has no other effects. For example, if `removeNotify` is called on a Canvas implementation for which a GLDrawable has been created, it is also necessary to destroy all OpenGL contexts associated with that GLDrawable. This is not done automatically by the implementation. It is not necessary to call `setRealized` on a GLCanvas, a GLJPanel, or a GLPbuffer, as these perform the appropriate calls on their underlying GLDrawables internally..

### setSize

    void setSize(int width,
                 int height)

  Requests a new width and height for this GLDrawable. Not all drawables are able to respond to this request and may silently ignore it.

### getWidth

    int getWidth()

  Returns the current width of this GLDrawable.

### getHeight

    int getHeight()

  Returns the current height of this GLDrawable.

### swapBuffers

    void swapBuffers()
                     throws GLException

  Swaps the front and back buffers of this drawable. For `GLAutoDrawable` implementations, when automatic buffer swapping is enabled (as is the default), this method is called automatically and should not be called by the end user.

  Throws:
    `GLException`

### getChosenGLCapabilities

    GLCapabilities getChosenGLCapabilities()

  Fetches the `GLCapabilities` corresponding to the chosen OpenGL capabilities (pixel format / visual) for this drawable. Some drawables, in particular on-screen drawables, may be created lazily; null is returned if the drawable is not currently created or if its pixel format has not been set yet. On some platforms, the pixel format is not directly associated with the drawable; a best attempt is made to return a reasonable value in this case.

Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.