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

public Class TileRenderer

extends TileRendererBase
Class Inheritance
Imports
com.jogamp.nativewindow.util.Dimension, .DimensionImmutable, com.jogamp.opengl.GL, .GL2ES3, .GLException, com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes

A fairly direct port of Brian Paul's tile rendering library, found at http://www.mesa3d.org/brianp/TR.html . I've java-fied it, but the functionality is the same.

Original code Copyright (C) 1997-2005 Brian Paul. Licensed under BSD-compatible terms with permission of the author. See LICENSE.txt for license information.

Enhanced for GL2ES3.

See TileRendererBase for details.

Author
ryanm, sgothel

Field Summary

Modifier and TypeField and Description
private int
private int
private int
private int
private static final int
private static final int
private static final int
private Dimension
private boolean
private int
private int
private int
private int
private int
private final Dimension
private final Dimension
public static final int
TR_BOTTOM_TO_TOP

Indicates we are traversing rows from the bottom to the top (default).

public static final int
TR_COLUMNS

The number of columns of tiles.

public static final int
TR_CURRENT_COLUMN

The current column number.

public static final int
TR_CURRENT_ROW

The current row number.

public static final int
TR_CURRENT_TILE_NUM

The current tile number.

public static final int
TR_IMAGE_CLIPPING_HEIGHT

The height of the final clipped image.

public static final int
TR_IMAGE_CLIPPING_WIDTH

The width of the final clipped image.

public static final int
TR_ROW_ORDER

The order that the rows are traversed.

public static final int
TR_ROWS

The number of rows of tiles.

public static final int
TR_TILE_BORDER

The width of the border around the tiles.

public static final int
TR_TILE_HEIGHT

The height of the tiles.

public static final int
TR_TILE_WIDTH

The width of the tiles.

public static final int
TR_TILE_X_OFFSET

The tiles x-offset.

public static final int
TR_TILE_Y_OFFSET

The tiles y-offset.

public static final int
TR_TOP_TO_BOTTOM

Indicates we are traversing rows from the top to the bottom.

Inherited from com.jogamp.opengl.util.TileRendererBase:
beginCalledcurrentTileHeightcurrentTileWidthcurrentTileXPoscurrentTileYPosDEBUGgladgladAutoSwapBufferModegladRequiresPreSwapglEventListenerPostglEventListenerPreimageBufferimageSizelistenerslistenersInitpsmtileBufferTR_CURRENT_TILE_HEIGHTTR_CURRENT_TILE_WIDTHTR_CURRENT_TILE_X_POSTR_CURRENT_TILE_Y_POSTR_IMAGE_HEIGHTTR_IMAGE_WIDTH

Constructor Summary

AccessConstructor and Description
public
TileRenderer()

Creates a new TileRenderer object

Method Summary

Modifier and TypeMethod and Description
public final void
beginTile(final GL
The gl context
gl
)

Implements abstract com.jogamp.opengl.util.TileRendererBase.beginTile.

Begins rendering a tile.
public final void
clipImageSize(final int
The image-clipping.width
width
,
final int
The image-clipping.height
height
)

Clips the image-size this tile-renderer iterates through, which can be retrieved via getClippedImageSize().

public void
endTile(final GL
the gl context
gl
)

Implements abstract com.jogamp.opengl.util.TileRendererBase.endTile.

Must be called after rendering the scene, see beginTile(GL).
public final boolean
eot()

Implements abstract com.jogamp.opengl.util.TileRendererBase.eot.

Returns true if end of tiling has been reached, otherwise false.
public final DimensionImmutable
getClippedImageSize()

Returns the clipped image-size.

pack-priv final int
public final int
getParam(final int
The parameter name that is to be retrieved
pname
)

Implements abstract com.jogamp.opengl.util.TileRendererBase.getParam.

Gets the parameters of this TileRenderer object
public final boolean
isSetup()

Implements abstract com.jogamp.opengl.util.TileRendererBase.isSetup.

Returns true if this instance is setup properly, i.e. setImageSize(int, int) .., and ready for beginTile(GL).
public final void
reset()

Implements abstract com.jogamp.opengl.util.TileRendererBase.reset.

Method resets implementation's internal state to start of tiling as required for beginTile(GL) if end of tiling has been reached.
public final void
setImageSize(final int
The width of the final image
width
,
final int
The height of the final image
height
)

Overrides com.jogamp.opengl.util.TileRendererBase.setImageSize.

Sets the desired size of the final image

Implementation reset() internal states.

public final void
setRowOrder(final int
The row traversal order, must be either TR_TOP_TO_BOTTOM or TR_BOTTOM_TO_TOP.
order
)

Sets the order of row traversal, default is TR_BOTTOM_TO_TOP.

public void
setTileOffset(final int xoff, final int yoff)

Sets an xy offset for the resulting tiles x-pos and y-pos.

public final void
setTileSize(final int
The width of the tiles. Must not be larger than the GL context
width
,
final int
The height of the tiles. Must not be larger than the GL context
height
,
final int
The width of the borders on each tile. This is needed to avoid artifacts when rendering lines or points with thickness > 1.
border
)

Sets the size of the tiles to use in rendering.

protected StringBuilder
Inherited from com.jogamp.opengl.util.TileRendererBase:
attachAutoDrawabledetachAutoDrawabledisplaygetAttachedDrawablegetImageBuffergetImageSizegetTileBufferreqPreSwapBufferssetGLEventListenersetImageBuffersetTileBuffertoStringtoStringvalidateGL

Field Detail

columnsback to summary
private int columns
currentColumnback to summary
private int currentColumn
currentRowback to summary
private int currentRow
currentTileback to summary
private int currentTile
DEFAULT_TILE_BORDERback to summary
private static final int DEFAULT_TILE_BORDER
DEFAULT_TILE_HEIGHTback to summary
private static final int DEFAULT_TILE_HEIGHT
DEFAULT_TILE_WIDTHback to summary
private static final int DEFAULT_TILE_WIDTH
imageClippingDimback to summary
private Dimension imageClippingDim
isInitback to summary
private boolean isInit
offsetXback to summary
private int offsetX
offsetYback to summary
private int offsetY
rowOrderback to summary
private int rowOrder
rowsback to summary
private int rows
tileBorderback to summary
private int tileBorder
tileSizeback to summary
private final Dimension tileSize
tileSizeNBback to summary
private final Dimension tileSizeNB
TR_BOTTOM_TO_TOPback to summary
public static final int TR_BOTTOM_TO_TOP

Indicates we are traversing rows from the bottom to the top (default). See getParam(int).

TR_COLUMNSback to summary
public static final int TR_COLUMNS

The number of columns of tiles. See getParam(int).

TR_CURRENT_COLUMNback to summary
public static final int TR_CURRENT_COLUMN

The current column number. See getParam(int).

TR_CURRENT_ROWback to summary
public static final int TR_CURRENT_ROW

The current row number. See getParam(int).

TR_CURRENT_TILE_NUMback to summary
public static final int TR_CURRENT_TILE_NUM

The current tile number. Has value -1 if eot(). See getParam(int).

TR_IMAGE_CLIPPING_HEIGHTback to summary
public static final int TR_IMAGE_CLIPPING_HEIGHT

The height of the final clipped image. See getParam(int).

TR_IMAGE_CLIPPING_WIDTHback to summary
public static final int TR_IMAGE_CLIPPING_WIDTH

The width of the final clipped image. See getParam(int).

TR_ROW_ORDERback to summary
public static final int TR_ROW_ORDER

The order that the rows are traversed. See getParam(int).

TR_ROWSback to summary
public static final int TR_ROWS

The number of rows of tiles. See getParam(int).

TR_TILE_BORDERback to summary
public static final int TR_TILE_BORDER

The width of the border around the tiles. See getParam(int).

TR_TILE_HEIGHTback to summary
public static final int TR_TILE_HEIGHT

The height of the tiles. See getParam(int).

TR_TILE_WIDTHback to summary
public static final int TR_TILE_WIDTH

The width of the tiles. See getParam(int).

TR_TILE_X_OFFSETback to summary
public static final int TR_TILE_X_OFFSET

The tiles x-offset. See getParam(int).

TR_TILE_Y_OFFSETback to summary
public static final int TR_TILE_Y_OFFSET

The tiles y-offset. See getParam(int).

TR_TOP_TO_BOTTOMback to summary
public static final int TR_TOP_TO_BOTTOM

Indicates we are traversing rows from the top to the bottom. See getParam(int).

Constructor Detail

TileRendererback to summary
public TileRenderer()

Creates a new TileRenderer object

Method Detail

beginTileback to summary
public final void beginTile(final GL gl) throws IllegalStateException, GLException

Implements abstract com.jogamp.opengl.util.TileRendererBase.beginTile.

Doc from com.jogamp.opengl.util.TileRendererBase.beginTile.

Begins rendering a tile.

This method modifies the viewport, see below. User shall reset the viewport when finishing all tile rendering, i.e. after very last call of endTile(GL)!

The PMV Matrix must be reshaped after this call using:

Use shall render the scene afterwards, concluded with a call to this renderer endTile(GL).

User has to comply with the GL profile requirement.

If end of tiling has been reached, user needs to reset() tiling before calling this method.

Parameters
gl:GL

The gl context

Annotations
@Override
Exceptions
IllegalStateException:
if image-size has not been set or end-of-tiling has been reached.
GLException:
if image buffer is used but gl instance is < GL2ES3
clipImageSizeback to summary
public final void clipImageSize(final int width, final int height)

Clips the image-size this tile-renderer iterates through, which can be retrieved via getClippedImageSize().

Original image-size stored in this tile-renderer is unmodified.

Implementation reset() internal states.

Parameters
width:int

The image-clipping.width

height:int

The image-clipping.height

See Also
getClippedImageSize()
endTileback to summary
public void endTile(final GL gl) throws IllegalStateException, GLException

Implements abstract com.jogamp.opengl.util.TileRendererBase.endTile.

Doc from com.jogamp.opengl.util.TileRendererBase.endTile.

Must be called after rendering the scene, see beginTile(GL).

Please consider reqPreSwapBuffers(GLCapabilitiesImmutable) to determine whether you need to perform swap-buffers before or after calling this method!

User has to comply with the GL profile requirement.

Parameters
gl:GL

the gl context

Annotations
@Override
Exceptions
IllegalStateException:
if beginTile(gl) has not been called
GLException:
if image buffer is used but gl instance is < GL2ES3
eotback to summary
public final boolean eot()

Implements abstract com.jogamp.opengl.util.TileRendererBase.eot.

Doc from com.jogamp.opengl.util.TileRendererBase.eot.

Returns true if end of tiling has been reached, otherwise false.

end of tiling criteria is implementation specific and may never be reached.

User needs to reset() tiling after reaching end of tiling before calling beginTile(GL) again.

end of tiling is reached w/ TileRenderer, if at least one of the following is true:

Annotations
@Override
getClippedImageSizeback to summary
public final DimensionImmutable getClippedImageSize()

Returns the clipped image-size.

If a image-size is clipped via clipImageSize(int, int), method returns:

  • min( image-clipping, image-size ), otherwise
  • image-size

The clipping width and height can be retrieved via TR_IMAGE_CLIPPING_WIDTH TR_IMAGE_CLIPPING_HEIGHT.

getCurrentTileback to summary
pack-priv final int getCurrentTile()
getParamback to summary
public final int getParam(final int pname)

Implements abstract com.jogamp.opengl.util.TileRendererBase.getParam.

Doc from com.jogamp.opengl.util.TileRendererBase.getParam.

Gets the parameters of this TileRenderer object

Parameters
pname:int

The parameter name that is to be retrieved

Returns:int

the value of the parameter

Annotations
@Override
isSetupback to summary
public final boolean isSetup()

Implements abstract com.jogamp.opengl.util.TileRendererBase.isSetup.

Doc from com.jogamp.opengl.util.TileRendererBase.isSetup.

Returns true if this instance is setup properly, i.e. setImageSize(int, int) .., and ready for beginTile(GL). Otherwise returns false.

Annotations
@Override
resetback to summary
public final void reset()

Implements abstract com.jogamp.opengl.util.TileRendererBase.reset.

Doc from com.jogamp.opengl.util.TileRendererBase.reset.

Method resets implementation's internal state to start of tiling as required for beginTile(GL) if end of tiling has been reached.

Implementation is a nop where end of tiling is never reached.

Reset internal states of TileRenderer are:
Annotations
@Override
setImageSizeback to summary
public final void setImageSize(final int width, final int height)

Overrides com.jogamp.opengl.util.TileRendererBase.setImageSize.

Doc from com.jogamp.opengl.util.TileRendererBase.setImageSize.

Sets the desired size of the final image

Implementation reset() internal states.

Parameters
width:int

The width of the final image

height:int

The height of the final image

Annotations
@Override
setRowOrderback to summary
public final void setRowOrder(final int order)

Sets the order of row traversal, default is TR_BOTTOM_TO_TOP.

Parameters
order:int

The row traversal order, must be either TR_TOP_TO_BOTTOM or TR_BOTTOM_TO_TOP.

setTileOffsetback to summary
public void setTileOffset(final int xoff, final int yoff)

Sets an xy offset for the resulting tiles x-pos and y-pos.

See Also
TR_TILE_X_OFFSET, TR_TILE_Y_OFFSET
setTileSizeback to summary
public final void setTileSize(final int width, final int height, final int border)

Sets the size of the tiles to use in rendering. The actual effective size of the tile depends on the border size, ie ( width - 2*border ) * ( height - 2 * border )

Implementation reset() internal states.

Parameters
width:int

The width of the tiles. Must not be larger than the GL context

height:int

The height of the tiles. Must not be larger than the GL context

border:int

The width of the borders on each tile. This is needed to avoid artifacts when rendering lines or points with thickness > 1.

tileDetailsback to summary
protected StringBuilder tileDetails(final StringBuilder sb)

Overrides com.jogamp.opengl.util.TileRendererBase.tileDetails.

Annotations
@Override