Top Description Fields Constructors Methods
com.jogamp.opengl.util.awt

public Class Overlay

extends Object
Class Inheritance
Imports
java.awt.Graphics2D, com.jogamp.opengl.*

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.

Field Summary

Modifier and TypeField and Description
private boolean
private final GLDrawable
private TextureRenderer

Constructor Summary

AccessConstructor and Description
public
Overlay(final GLDrawable drawable)

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

Method Summary

Modifier and TypeMethod and Description
public void
beginRendering()

Begins the OpenGL rendering process for the overlay.

public boolean

Returns:

whether the contents of the overlay were lost since the last render
contentsLost
()

Indicates whether the Java 2D contents of the overlay were lost since the last time createGraphics was called.

public Graphics2D

Returns:

a new Graphics2D object for rendering into the backing store of this renderer
createGraphics
()

Creates a Graphics2D instance for rendering into the overlay.

public void
draw(final int
the lower-left x coordinate (relative to the lower left of the overlay) of the rectangle to draw
x
,
final int
the lower-left y coordinate (relative to the lower left of the overlay) of the rectangle to draw
y
,
final int
the width of the rectangle to draw
width
,
final int
the height of the rectangle to draw
height
)

Draws the specified sub-rectangle of the overlay on top of the OpenGL drawable.

public void
draw(final int
the on-screen x coordinate at which to draw the rectangle
screenx
,
final int
the on-screen y coordinate (relative to lower left) at which to draw the rectangle
screeny
,
final int
the x coordinate of the pixel in the overlay of the lower left portion of the rectangle to draw
overlayx
,
final int
the y coordinate of the pixel in the overlay (relative to lower left) of the lower left portion of the rectangle to draw
overlayy
,
final int
the width of the rectangle to draw
width
,
final int
the height of the rectangle to draw
height
)

Draws the specified sub-rectangle of the overlay at the specified x and y coordinate on top of the OpenGL drawable.

public void
drawAll()

Draws the entire contents of the overlay on top of the OpenGL drawable.

public void
endRendering()

Ends the OpenGL rendering process for the overlay.

public void
markDirty(final int
the x coordinate (in Java 2D coordinates -- relative to upper left) of the region to update
x
,
final int
the y coordinate (in Java 2D coordinates -- relative to upper left) of the region to update
y
,
final int
the width of the region to update
width
,
final int
the height of the region to update
height
)

Marks the given region of the overlay as dirty.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentsLostback to summary
private boolean contentsLost
drawableback to summary
private final GLDrawable drawable
rendererback to summary
private TextureRenderer renderer

Constructor Detail

Overlayback to summary
public Overlay(final GLDrawable drawable)

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

Method Detail

beginRenderingback to summary
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.

Exceptions
GLException:
If an OpenGL context is not current when this method is called
contentsLostback to summary
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:boolean

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

createGraphicsback to summary
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:Graphics2D

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

drawback to summary
public void draw(final int x, final int y, final int width, final 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:int

the lower-left x coordinate (relative to the lower left of the overlay) of the rectangle to draw

y:int

the lower-left y coordinate (relative to the lower left of the overlay) of the rectangle to draw

width:int

the width of the rectangle to draw

height:int

the height of the rectangle to draw

Exceptions
GLException:
If an OpenGL context is not current when this method is called
drawback to summary
public void draw(final int screenx, final int screeny, final int overlayx, final int overlayy, final int width, final 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:int

the on-screen x coordinate at which to draw the rectangle

screeny:int

the on-screen y coordinate (relative to lower left) at which to draw the rectangle

overlayx:int

the x coordinate of the pixel in the overlay of the lower left portion of the rectangle to draw

overlayy:int

the y coordinate of the pixel in the overlay (relative to lower left) of the lower left portion of the rectangle to draw

width:int

the width of the rectangle to draw

height:int

the height of the rectangle to draw

Exceptions
GLException:
If an OpenGL context is not current when this method is called
drawAllback to summary
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.

Exceptions
GLException:
If an OpenGL context is not current when this method is called
endRenderingback to summary
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.

Exceptions
GLException:
If an OpenGL context is not current when this method is called
markDirtyback to summary
public void markDirty(final int x, final int y, final int width, final 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:int

the x coordinate (in Java 2D coordinates -- relative to upper left) of the region to update

y:int

the y coordinate (in Java 2D coordinates -- relative to upper left) of the region to update

width:int

the width of the region to update

height:int

the height of the region to update

Exceptions
GLException:
If an OpenGL context is not current when this method is called
validateRendererback to summary
private void validateRenderer()