Texture using the Java 2D
APIs. This renderer class uses an internal Java 2D image (of
unspecified type) for its backing store and flushes portions of
that image to an OpenGL texture on demand. The resulting OpenGL
texture can then be mapped on to a polygon for display.
| Modifier and Type | Field and Description |
|---|---|
| private float | |
| private final boolean | |
| private float | |
| private float[] | |
| private Rectangle | |
| private float | |
| private final GLUgl2 | |
| private BufferedImage | |
| private final boolean | |
| private boolean | |
| private boolean | |
| private float | |
| private boolean | |
| private boolean | |
| private Texture | |
| private AWTTextureData |
| Access | Constructor and Description |
|---|---|
| public | TextureRenderer(final int
the width of the texture to render into width, final int the height of the texture to render into height, final boolean whether to allocate an alpha channel for the texture alpha)Creates a new renderer with backing store of the specified width and height. |
| public | TextureRenderer(final int
the width of the texture to render into width, final int the height of the texture to render into height, final boolean whether to allocate an alpha channel for the texture alpha, final boolean whether to attempt use of automatic mipmap generation mipmap)Creates a new renderer with backing store of the specified width and height. |
| private | TextureRenderer(final int width, final int height, final boolean alpha, final boolean intensity, final boolean mipmap)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | begin3DRendering()
Convenience method which assists in rendering portions of the OpenGL texture to the screen as 2D quads in 3D space. |
| public void | beginOrthoRendering(final int
the width of the current on-screen OpenGL drawable width, final int the height of the current on-screen OpenGL drawable height)Convenience method which assists in rendering portions of the OpenGL texture to the screen, if the application intends to draw them as a flat overlay on to the screen. |
| public void | beginOrthoRendering(final int
the width of the current on-screen OpenGL drawable width, final int the height of the current on-screen OpenGL drawable height, final boolean whether the depth test should be disabled disableDepthTest)Convenience method which assists in rendering portions of the OpenGL texture to the screen, if the application intends to draw them as a flat overlay on to the screen. |
| private void | beginRendering(final boolean ortho, final int width, final int height, final boolean disableDepthTestForOrtho)
|
| public static TextureRenderer | createAlphaOnlyRenderer(final int width, final int height)
Creates a new renderer with a special kind of backing store which acts only as an alpha channel. |
| public static TextureRenderer | createAlphaOnlyRenderer(final int width, final int height, final boolean mipmap)
Creates a new renderer with a special kind of backing store which acts only as an alpha channel. |
| public Graphics2D | Returns: a newGraphics2D object for
rendering into the backing store of this rendererCreates a |
| public void | |
| public void | draw3DRect(final float
the x coordinate at which to draw the rectangle x, final float the y coordinate at which to draw the rectangle y, final float the z coordinate at which to draw the rectangle z, final int the x coordinate of the pixel in the texture of
the lower left portion of the rectangle to draw texturex, final int the y coordinate of the pixel in the texture
(relative to lower left) of the lower left portion of the
rectangle to draw texturey, final int the width in texels of the rectangle to draw width, final int the height in texels of the rectangle to draw height, final float the scale factor to apply (multiplicatively)
to the size of the drawn rectangle scaleFactor)Draws a rectangle of the underlying texture to the specified 3D location. |
| public void | drawOrthoRect(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)Draws an orthographically projected rectangle containing all of the underlying texture to the specified location on the screen. |
| public void | drawOrthoRect(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 texture of
the lower left portion of the rectangle to draw texturex, final int the y coordinate of the pixel in the texture
(relative to lower left) of the lower left portion of the
rectangle to draw texturey, final int the width of the rectangle to draw width, final int the height of the rectangle to draw height)Draws an orthographically projected rectangle of the underlying texture to the specified location on the screen. |
| public void | end3DRendering()
Convenience method which assists in rendering portions of the OpenGL texture to the screen as 2D quads in 3D space. |
| public void | endOrthoRendering()
Convenience method which assists in rendering portions of the OpenGL texture to the screen, if the application intends to draw them as a flat overlay on to the screen. |
| private void | |
| private boolean | |
| public int | Returns: the height of the backing store of this rendererReturns the height of the backing store of this renderer. |
| public Image | |
| public Dimension | |
| public Dimension | |
| public boolean | Returns: whether smoothing is enabled for the OpenGL textureReturns whether smoothing is enabled for the OpenGL texture; see
|
| public Texture | getTexture()
Returns the underlying OpenGL Texture object associated with this renderer, synchronizing any dirty regions of the TextureRenderer with the underlying OpenGL texture. |
| public int | Returns: the width of the backing store of this rendererReturns the width of the backing store of this renderer. |
| private void | |
| public boolean | isUsingAutoMipmapGeneration()
Indicates whether automatic mipmap generation is in use for this TextureRenderer. |
| 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 TextureRenderer as dirty. |
| public void | setColor(final float
the red component of the new color r, final float the green component of the new color g, final float the blue component of the new color b, final float the alpha component of the new color, 0.0f = completely
transparent, 1.0f = completely opaque a)Changes the color of the polygons, and therefore the drawn images, this TextureRenderer produces. |
| public void | |
| public void | setSize(final int
the new width of the backing store of this renderer width, final int the new height of the backing store of this renderer height)Sets the size of the backing store of this renderer. |
| public void | |
| public void | setSmoothing(final boolean
whether smoothing is enabled for the OpenGL texture smoothing)Sets whether smoothing is enabled for the OpenGL texture; if so, uses GL_LINEAR interpolation for the minification and magnification filters. |
| private void | sync(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)Synchronizes the specified region of the backing store down to the underlying OpenGL texture. |
| a | back to summary |
|---|---|
| private float a | |
| alpha | back to summary |
|---|---|
| private final boolean alpha | |
| b | back to summary |
|---|---|
| private float b | |
| compArray | back to summary |
|---|---|
| private float[] compArray | |
| dirtyRegion | back to summary |
|---|---|
| private Rectangle dirtyRegion | |
| g | back to summary |
|---|---|
| private float g | |
| glu | back to summary |
|---|---|
| private final GLUgl2 glu | |
| image | back to summary |
|---|---|
| private BufferedImage image | |
| intensity | back to summary |
|---|---|
| private final boolean intensity | |
| mipmap | back to summary |
|---|---|
| private boolean mipmap | |
| mustReallocateTexture | back to summary |
|---|---|
| private boolean mustReallocateTexture | |
| r | back to summary |
|---|---|
| private float r | |
| smoothing | back to summary |
|---|---|
| private boolean smoothing | |
| smoothingChanged | back to summary |
|---|---|
| private boolean smoothingChanged | |
| texture | back to summary |
|---|---|
| private Texture texture | |
| textureData | back to summary |
|---|---|
| private AWTTextureData textureData | |
| TextureRenderer | back to summary |
|---|---|
| public TextureRenderer(final int width, final int height, final boolean alpha) Creates a new renderer with backing store of the specified width
and height. If
| |
| TextureRenderer | back to summary |
|---|---|
| public TextureRenderer(final int width, final int height, final boolean alpha, final boolean mipmap) Creates a new renderer with backing store of the specified width
and height. If
| |
| TextureRenderer | back to summary |
|---|---|
| private TextureRenderer(final int width, final int height, final boolean alpha, final boolean intensity, final boolean mipmap) | |
| begin3DRendering | back to summary |
|---|---|
| public void begin3DRendering() throws GLException Convenience method which assists in rendering portions of the
OpenGL texture to the screen as 2D quads in 3D space. Pushes
OpenGL state (GL_ENABLE_BIT); disables lighting; and enables the
texture in this renderer. Unlike
| |
| beginOrthoRendering | back to summary |
|---|---|
| public void beginOrthoRendering(final int width, final int height) throws GLException Convenience method which assists in rendering portions of the
OpenGL texture to the screen, if the application intends to draw
them as a flat overlay on to the screen. Pushes OpenGL state
bits (GL_ENABLE_BIT, GL_DEPTH_BUFFER_BIT and GL_TRANSFORM_BIT);
disables the depth test, back-face culling, and lighting;
enables the texture in this renderer; and sets up the viewing
matrices for orthographic rendering where the coordinates go
from (0, 0) at the lower left to (width, height) at the upper
right. Equivalent to beginOrthoRendering(width, height, true).
| |
| beginOrthoRendering | back to summary |
|---|---|
| public void beginOrthoRendering(final int width, final int height, final boolean disableDepthTest) throws GLException Convenience method which assists in rendering portions of the
OpenGL texture to the screen, if the application intends to draw
them as a flat overlay on to the screen. Pushes OpenGL state
bits (GL_ENABLE_BIT, GL_DEPTH_BUFFER_BIT and GL_TRANSFORM_BIT);
disables the depth test (if the "disableDepthTest" argument is
true), back-face culling, and lighting; enables the texture in
this renderer; and sets up the viewing matrices for orthographic
rendering where the coordinates go from (0, 0) at the lower left
to (width, height) at the upper right.
| |
| beginRendering | back to summary |
|---|---|
| private void beginRendering(final boolean ortho, final int width, final int height, final boolean disableDepthTestForOrtho) | |
| createAlphaOnlyRenderer | back to summary |
|---|---|
| public static TextureRenderer createAlphaOnlyRenderer(final int width, final int height) Creates a new renderer with a special kind of backing store which acts only as an alpha channel. No mipmap support is requested. Internally, this associates a GL_INTENSITY OpenGL texture with the backing store. | |
| createAlphaOnlyRenderer | back to summary |
|---|---|
| public static TextureRenderer createAlphaOnlyRenderer(final int width, final int height, final boolean mipmap) Creates a new renderer with a special kind of backing store
which acts only as an alpha channel. If | |
| createGraphics | back to summary |
|---|---|
| public Graphics2D createGraphics() Creates a
| |
| dispose | back to summary |
|---|---|
| public void dispose() throws GLException Disposes all resources associated with this renderer. It is not valid to use this renderer after calling this method.
| |
| draw3DRect | back to summary |
|---|---|
| public void draw3DRect(final float x, final float y, final float z, final int texturex, final int texturey, final int width, final int height, final float scaleFactor) throws GLException Draws a rectangle of the underlying texture to the specified 3D location. In the current coordinate system, the lower left corner of the rectangle is placed at (x, y, z), and the upper right corner is placed at (x + width * scaleFactor, y + height * scaleFactor, z). The lower left corner of the sub-rectangle of the texture is (texturex, texturey) and the upper right corner is (texturex + width, texturey + height). For back-face culling purposes, the rectangle is drawn with counterclockwise orientation of the vertices when viewed from the front.
| |
| drawOrthoRect | back to summary |
|---|---|
| public void drawOrthoRect(final int screenx, final int screeny) throws GLException Draws an orthographically projected rectangle containing all of
the underlying texture to the specified location on the
screen. All (x, y) coordinates are specified relative to the
lower left corner of either the texture image or the current
OpenGL drawable. This method is equivalent to
| |
| drawOrthoRect | back to summary |
|---|---|
| public void drawOrthoRect(final int screenx, final int screeny, final int texturex, final int texturey, final int width, final int height) throws GLException Draws an orthographically projected rectangle of the underlying texture to the specified location on the screen. All (x, y) coordinates are specified relative to the lower left corner of either the texture image or the current OpenGL drawable.
| |
| end3DRendering | back to summary |
|---|---|
| public void end3DRendering() throws GLException Convenience method which assists in rendering portions of the
OpenGL texture to the screen as 2D quads in 3D space. Must be
used if
| |
| endOrthoRendering | back to summary |
|---|---|
| public void endOrthoRendering() throws GLException Convenience method which assists in rendering portions of the
OpenGL texture to the screen, if the application intends to draw
them as a flat overlay on to the screen. Must be used if
| |
| endRendering | back to summary |
|---|---|
| private void endRendering(final boolean ortho) | |
| ensureTexture | back to summary |
|---|---|
| private boolean ensureTexture() | |
| getHeight | back to summary |
|---|---|
| public int getHeight() Returns the height of the backing store of this renderer.
| |
| getImage | back to summary |
|---|---|
| public Image getImage() Returns the underlying Java 2D | |
| getSize | back to summary |
|---|---|
| public Dimension getSize() Returns the size of the backing store of this renderer in a
newly-allocated
| |
| getSize | back to summary |
|---|---|
| public Dimension getSize(Dimension d) Returns the size of the backing store of this renderer. Uses the
| |
| getSmoothing | back to summary |
|---|---|
| public boolean getSmoothing() Returns whether smoothing is enabled for the OpenGL texture; see
| |
| getTexture | back to summary |
|---|---|
| public Texture getTexture() throws GLException Returns the underlying OpenGL Texture object associated with this renderer, synchronizing any dirty regions of the TextureRenderer with the underlying OpenGL texture.
| |
| getWidth | back to summary |
|---|---|
| public int getWidth() Returns the width of the backing store of this renderer.
| |
| init | back to summary |
|---|---|
| private void init(final int width, final int height) | |
| isUsingAutoMipmapGeneration | back to summary |
|---|---|
| public boolean isUsingAutoMipmapGeneration() Indicates whether automatic mipmap generation is in use for this TextureRenderer. The result of this method may change from true to false if it is discovered during allocation of the TextureRenderer's backing store that automatic mipmap generation is not supported at the OpenGL level. | |
| markDirty | back to summary |
|---|---|
| public void markDirty(final int x, final int y, final int width, final int height) Marks the given region of the TextureRenderer as dirty. This
region, and any previously set dirty regions, will be
automatically synchronized with the underlying Texture during
the next
| |
| setColor | back to summary |
|---|---|
| public void setColor(final float r, final float g, final float b, final float a) throws GLException Changes the color of the polygons, and therefore the drawn images, this TextureRenderer produces. Use of this method is optional. The TextureRenderer uses the GL_MODULATE texture environment mode, which causes the portions of the rendered texture to be multiplied by the color of the rendered polygons. The polygon color can be varied to achieve effects like tinting of the overall output or fading in and out by changing the alpha of the color.
Each component ranges from 0.0f - 1.0f. The alpha component, if
used, does not need to be premultiplied into the color channels
as described in the documentation for
| |
| setColor | back to summary |
|---|---|
| public void setColor(final Color color) throws GLException Changes the current color of this TextureRenderer to the
supplied one. The default color is opaque white. See
| |
| setSize | back to summary |
|---|---|
| public void setSize(final int width, final int height) throws GLException Sets the size of the backing store of this renderer. This may
cause the OpenGL texture object associated with this renderer to
be invalidated; it is not recommended to cache this texture
object outside this class but to instead call
| |
| setSize | back to summary |
|---|---|
| public void setSize(final Dimension d) throws GLException Sets the size of the backing store of this renderer. This may cause the OpenGL texture object associated with this renderer to be invalidated.
| |
| setSmoothing | back to summary |
|---|---|
| public void setSmoothing(final boolean smoothing) Sets whether smoothing is enabled for the OpenGL texture; if so,
uses GL_LINEAR interpolation for the minification and
magnification filters. Defaults to true. Changes to this setting
will not take effect until the next call to
| |
| sync | back to summary |
|---|---|
| private void sync(final int x, final int y, final int width, final int height) throws GLException Synchronizes the specified region of the backing store down to
the underlying OpenGL texture. If
| |