Class TileRenderer
- java.lang.Object
-
- com.jogamp.opengl.util.TileRendererBase
-
- com.jogamp.opengl.util.TileRenderer
-
public class TileRenderer extends TileRendererBase
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
TileRendererBasefor details.- Author:
- ryanm, sgothel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.jogamp.opengl.util.TileRendererBase
TileRendererBase.TileRendererListener
-
-
Field Summary
Fields Modifier and Type Field Description static intTR_BOTTOM_TO_TOPIndicates we are traversing rows from the bottom to the top (default).static intTR_COLUMNSThe number of columns of tiles.static intTR_CURRENT_COLUMNThe current column number.static intTR_CURRENT_ROWThe current row number.static intTR_CURRENT_TILE_NUMThe current tile number.static intTR_IMAGE_CLIPPING_HEIGHTThe height of the final clipped image.static intTR_IMAGE_CLIPPING_WIDTHThe width of the final clipped image.static intTR_ROW_ORDERThe order that the rows are traversed.static intTR_ROWSThe number of rows of tiles.static intTR_TILE_BORDERThe width of the border around the tiles.static intTR_TILE_HEIGHTThe height of the tiles.static intTR_TILE_WIDTHThe width of the tiles.static intTR_TILE_X_OFFSETThe tiles x-offset.static intTR_TILE_Y_OFFSETThe tiles y-offset.static intTR_TOP_TO_BOTTOMIndicates we are traversing rows from the top to the bottom.-
Fields inherited from class com.jogamp.opengl.util.TileRendererBase
TR_CURRENT_TILE_HEIGHT, TR_CURRENT_TILE_WIDTH, TR_CURRENT_TILE_X_POS, TR_CURRENT_TILE_Y_POS, TR_IMAGE_HEIGHT, TR_IMAGE_WIDTH
-
-
Constructor Summary
Constructors Constructor Description TileRenderer()Creates a new TileRenderer object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginTile(GL gl)Begins rendering a tile.voidclipImageSize(int width, int height)Clips the image-size this tile-renderer iterates through, which can be retrieved viagetClippedImageSize().voidendTile(GL gl)Must be called after rendering the scene, seeTileRendererBase.beginTile(GL).booleaneot()Returns true if end of tiling has been reached, otherwise false.DimensionImmutablegetClippedImageSize()Returns the clipped image-size.intgetParam(int pname)Gets the parameters of this TileRenderer objectbooleanisSetup()Returns true if this instance is setup properly, i.e.voidreset()Method resets implementation's internal state to start of tiling as required forTileRendererBase.beginTile(GL)ifend of tilinghas been reached.voidsetImageSize(int width, int height)Sets the desired size of the final imagevoidsetRowOrder(int order)Sets the order of row traversal, default isTR_BOTTOM_TO_TOP.voidsetTileOffset(int xoff, int yoff)voidsetTileSize(int width, int height, int border)Sets the size of the tiles to use in rendering.-
Methods inherited from class com.jogamp.opengl.util.TileRendererBase
attachAutoDrawable, detachAutoDrawable, display, getAttachedDrawable, getImageBuffer, getImageSize, getTileBuffer, reqPreSwapBuffers, setGLEventListener, setImageBuffer, setTileBuffer, toString, toString
-
-
-
-
Field Detail
-
TR_IMAGE_CLIPPING_WIDTH
public static final int TR_IMAGE_CLIPPING_WIDTH
The width of the final clipped image. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_IMAGE_CLIPPING_HEIGHT
public static final int TR_IMAGE_CLIPPING_HEIGHT
The height of the final clipped image. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TILE_WIDTH
public static final int TR_TILE_WIDTH
The width of the tiles. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TILE_HEIGHT
public static final int TR_TILE_HEIGHT
The height of the tiles. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TILE_BORDER
public static final int TR_TILE_BORDER
The width of the border around the tiles. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TILE_X_OFFSET
public static final int TR_TILE_X_OFFSET
The tiles x-offset. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TILE_Y_OFFSET
public static final int TR_TILE_Y_OFFSET
The tiles y-offset. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_ROWS
public static final int TR_ROWS
The number of rows of tiles. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_COLUMNS
public static final int TR_COLUMNS
The number of columns of tiles. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_CURRENT_TILE_NUM
public static final int TR_CURRENT_TILE_NUM
The current tile number. Has value -1 ifeot(). SeegetParam(int).- See Also:
- Constant Field Values
-
TR_CURRENT_ROW
public static final int TR_CURRENT_ROW
The current row number. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_CURRENT_COLUMN
public static final int TR_CURRENT_COLUMN
The current column number. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_ROW_ORDER
public static final int TR_ROW_ORDER
The order that the rows are traversed. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_TOP_TO_BOTTOM
public static final int TR_TOP_TO_BOTTOM
Indicates we are traversing rows from the top to the bottom. SeegetParam(int).- See Also:
- Constant Field Values
-
TR_BOTTOM_TO_TOP
public static final int TR_BOTTOM_TO_TOP
Indicates we are traversing rows from the bottom to the top (default). SeegetParam(int).- See Also:
- Constant Field Values
-
-
Method Detail
-
setImageSize
public final void setImageSize(int width, int height)Sets the desired size of the final imageImplementation
reset()internal states.- Overrides:
setImageSizein classTileRendererBase- Parameters:
width- The width of the final imageheight- The height of the final image
-
clipImageSize
public final void clipImageSize(int width, int height)Clips the image-size this tile-renderer iterates through, which can be retrieved viagetClippedImageSize().Original image-size stored in this tile-renderer is unmodified.
Implementation
reset()internal states.- Parameters:
width- The image-clipping.widthheight- The image-clipping.height- See Also:
getClippedImageSize()
-
getClippedImageSize
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 ), otherwiseimage-size
The clipping width and height can be retrieved via
TR_IMAGE_CLIPPING_WIDTHTR_IMAGE_CLIPPING_HEIGHT.
-
setTileSize
public final void setTileSize(int width, int height, 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- The width of the tiles. Must not be larger than the GL contextheight- The height of the tiles. Must not be larger than the GL contextborder- The width of the borders on each tile. This is needed to avoid artifacts when rendering lines or points with thickness > 1.
-
setTileOffset
public void setTileOffset(int xoff, int yoff)- See Also:
TR_TILE_X_OFFSET,TR_TILE_Y_OFFSET
-
reset
public final void reset()
Method resets implementation's internal state to start of tiling as required forTileRendererBase.beginTile(GL)ifend of tilinghas been reached.Implementation is a nop where
Reset internal states ofend of tilingis never reached.TileRendererare:- Specified by:
resetin classTileRendererBase
-
getParam
public final int getParam(int pname)
Description copied from class:TileRendererBaseGets the parameters of this TileRenderer object- Specified by:
getParamin classTileRendererBase- Parameters:
pname- The parameter name that is to be retrieved- Returns:
- the value of the parameter
-
setRowOrder
public final void setRowOrder(int order)
Sets the order of row traversal, default isTR_BOTTOM_TO_TOP.- Parameters:
order- The row traversal order, must be eitherTR_TOP_TO_BOTTOMorTR_BOTTOM_TO_TOP.
-
isSetup
public final boolean isSetup()
Description copied from class:TileRendererBaseReturns true if this instance is setup properly, i.e.TileRendererBase.setImageSize(int, int).., and ready forTileRendererBase.beginTile(GL). Otherwise returns false.- Specified by:
isSetupin classTileRendererBase
-
eot
public final boolean 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
TileRendererBase.reset()tiling after reaching end of tiling before callingTileRendererBase.beginTile(GL)again.end of tiling is reached w/
TileRenderer, if at least one of the following is true:- all tiles have been rendered, i.e.
TR_CURRENT_TILE_NUMis -1 - no tiles to render, i.e.
TR_COLUMNSorTR_ROWSis 0
- Specified by:
eotin classTileRendererBase
- all tiles have been rendered, i.e.
-
beginTile
public final void beginTile(GL gl) throws IllegalStateException, GLException
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
TileRendererBase.endTile(GL)!The PMV Matrix must be reshaped after this call using:
- Current Viewport
current tile's x-poscurrent tile's y-posfinal image widthfinal image height
Use shall render the scene afterwards, concluded with a call to this renderer
TileRendererBase.endTile(GL).User has to comply with the GL profile requirement.
If
end of tilinghas been reached, user needs toTileRendererBase.reset()tiling before calling this method.- Specified by:
beginTilein classTileRendererBase- Parameters:
gl- The gl context- Throws:
IllegalStateException- ifimage-sizehas not been set orend-of-tilinghas been reached.GLException- ifimage bufferis used butglinstance is <GL2ES3- See Also:
TileRendererBase.isSetup(),TileRendererBase.eot(),TileRendererBase.reset()
-
endTile
public void endTile(GL gl) throws IllegalStateException, GLException
Description copied from class:TileRendererBaseMust be called after rendering the scene, seeTileRendererBase.beginTile(GL).Please consider
TileRendererBase.reqPreSwapBuffers(GLCapabilitiesImmutable)to determine whether you need to performswap-buffersbefore or after calling this method!User has to comply with the GL profile requirement.
- Specified by:
endTilein classTileRendererBase- Parameters:
gl- the gl context- Throws:
IllegalStateException- if beginTile(gl) has not been calledGLException- ifimage bufferis used butglinstance is <GL2ES3
-
-