Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.opengl.util.j2d
Class Overlay

    java.lang.Object
      com.sun.opengl.util.j2d.Overlay

public class Overlay
extends Object

Provides a Java 2D overlay on top of an arbitrary GLDrawable, making it easier to do things like draw text and images on top of an OpenGL scene while still maintaining reasonably good efficiency.

Constructor Summary
`Overlay(GLDrawable drawable)` Creates a new Java 2D overlay on top of the specified GLDrawable.

Method Summary
`void` | `beginRendering()` Begins the OpenGL rendering process for the overlay.
`boolean` | `contentsLost()` Indicates whether the Java 2D contents of the overlay were lost since the last time `createGraphics()` was called.
`Graphics2D` | `createGraphics()` Creates a `Graphics2D` instance for rendering into the overlay.
`void` | `draw(int x, int y, int width, int height)` Draws the specified sub-rectangle of the overlay on top of the OpenGL drawable.
`void` | `draw(int screenx, int screeny, int overlayx, int overlayy, int width, int height)` Draws the specified sub-rectangle of the overlay at the specified x and y coordinate on top of the OpenGL drawable.
`void` | `drawAll()` Draws the entire contents of the overlay on top of the OpenGL drawable.
`void` | `endRendering()` Ends the OpenGL rendering process for the overlay.
`void` | `markDirty(int x, int y, int width, int height)` Marks the given region of the overlay as dirty.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Overlay

    public Overlay(GLDrawable drawable)

  Creates a new Java 2D overlay on top of the specified GLDrawable.

Method Detail

### createGraphics

    public Graphics2D createGraphics()

  Creates a `Graphics2D` instance for rendering into the overlay. The returned object should be disposed of using the normal `Graphics.dispose()` method once it is no longer being used.

  Returns:
    a new `Graphics2D` object for rendering into the backing store of this renderer

### contentsLost

    public boolean contentsLost()

  Indicates whether the Java 2D contents of the overlay were lost since the last time `createGraphics()` was called. This method should be called immediately after calling `createGraphics()` to see whether the entire contents of the overlay need to be redrawn or just the region the application is interested in updating.

  Returns:
    whether the contents of the overlay were lost since the last render

### markDirty

    public void markDirty(int x,
                          int y,
                          int width,
                          int height)

  Marks the given region of the overlay as dirty. This region, and any previously set dirty regions, will be automatically synchronized with the underlying Texture during the next `draw` or `drawAll` operation, at which point the dirty region will be cleared. It is not necessary for an OpenGL context to be current when this method is called.

  Parameters:
    `x` - the x coordinate (in Java 2D coordinates -- relative to upper left) of the region to update
    `y` - the y coordinate (in Java 2D coordinates -- relative to upper left) of the region to update
    `width` - the width of the region to update
    `height` - the height of the region to update
  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

### drawAll

    public void drawAll()
                 throws GLException

  Draws the entire contents of the overlay on top of the OpenGL drawable. This is a convenience method which encapsulates all portions of the rendering process; if this method is used, `beginRendering()`, `endRendering()`, etc. should not be used. This method should be called while the OpenGL context for the drawable is current, and after your OpenGL scene has been rendered.

  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

### beginRendering

    public void beginRendering()
                        throws GLException

  Begins the OpenGL rendering process for the overlay. This is separated out so advanced applications can render independent pieces of the overlay to different portions of the drawable.

  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

### endRendering

    public void endRendering()
                      throws GLException

  Ends the OpenGL rendering process for the overlay. This is separated out so advanced applications can render independent pieces of the overlay to different portions of the drawable.

  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

### draw

    public void draw(int x,
                     int y,
                     int width,
                     int height)
              throws GLException

  Draws the specified sub-rectangle of the overlay on top of the OpenGL drawable. `beginRendering()` and `endRendering()` must be used in conjunction with this method to achieve proper rendering results. This method should be called while the OpenGL context for the drawable is current, and after your OpenGL scene has been rendered.

  Parameters:
    `x` - the lower-left x coordinate (relative to the lower left of the overlay) of the rectangle to draw
    `y` - the lower-left y coordinate (relative to the lower left of the overlay) of the rectangle to draw
    `width` - the width of the rectangle to draw
    `height` - the height of the rectangle to draw
  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

### draw

    public void draw(int screenx,
                     int screeny,
                     int overlayx,
                     int overlayy,
                     int width,
                     int height)
              throws GLException

  Draws the specified sub-rectangle of the overlay at the specified x and y coordinate on top of the OpenGL drawable. `beginRendering()` and `endRendering()` must be used in conjunction with this method to achieve proper rendering results. This method should be called while the OpenGL context for the drawable is current, and after your OpenGL scene has been rendered.

  Parameters:
    `screenx` - the on-screen x coordinate at which to draw the rectangle
    `screeny` - the on-screen y coordinate (relative to lower left) at which to draw the rectangle
    `overlayx` - the x coordinate of the pixel in the overlay of the lower left portion of the rectangle to draw
    `overlayy` - the y coordinate of the pixel in the overlay (relative to lower left) of the lower left portion of the rectangle to draw
    `width` - the width of the rectangle to draw
    `height` - the height of the rectangle to draw
  Throws:
    `GLException` - If an OpenGL context is not current when this method is called

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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