com.sun.opengl.util

Class TileRenderer


public class TileRenderer
extends Object

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.
Author:
ryanm

Field Summary

static int
TR_BOTTOM_TO_TOP
Indicates we are traversing rows from the bottom to the top
static int
TR_COLUMNS
The number of columns of tiles
static int
TR_CURRENT_COLUMN
The current column number
static int
TR_CURRENT_ROW
The current row number
static int
TR_CURRENT_TILE_HEIGHT
The height of the current tile
static int
TR_CURRENT_TILE_WIDTH
The width of the current tile
static int
TR_IMAGE_HEIGHT
The height of the final image
static int
TR_IMAGE_WIDTH
The width of the final image
static int
TR_ROWS
The number of rows of tiles
static int
TR_ROW_ORDER
The order that the rows are traversed
static int
TR_TILE_BORDER
The width of the border around the tiles
static int
TR_TILE_HEIGHT
The height of a tile
static int
TR_TILE_WIDTH
The width of a tile
static int
TR_TOP_TO_BOTTOM
Indicates we are traversing rows from the top to the bottom

Constructor Summary

TileRenderer()
Creates a new TileRenderer object

Method Summary

void
beginTile(GL gl)
Begins rendering a tile.
boolean
endTile(GL gl)
Must be called after rendering the scene
int
getParam(int param)
Gets the parameters of this TileRenderer object
void
setImageBuffer(int format, int type, Buffer image)
Sets the buffer in which to store the final image
void
setImageSize(int width, int height)
Sets the desired size of the final image
void
setRowOrder(int order)
Sets the order of row traversal
void
setTileBuffer(int format, int type, Buffer image)
Specify a buffer the tiles to be copied to.
void
setTileSize(int width, int height, int border)
Sets the size of the tiles to use in rendering.
void
trFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
Sets the perspective projection frustrum.
void
trOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
Sets the context to use an orthographic projection.
void
trPerspective(double fovy, double aspect, double zNear, double zFar)
Convenient way to specify a perspective projection
void
trRasterPos3f(float x, float y, float z, GL gl, GLU glu)
Tile rendering causes problems with using glRasterPos3f, so you should use this replacement instead

Field Details

TR_BOTTOM_TO_TOP

public static final int TR_BOTTOM_TO_TOP
Indicates we are traversing rows from the bottom to the top
Field Value:
2

TR_COLUMNS

public static final int TR_COLUMNS
The number of columns of tiles
Field Value:
6

TR_CURRENT_COLUMN

public static final int TR_CURRENT_COLUMN
The current column number
Field Value:
8

TR_CURRENT_ROW

public static final int TR_CURRENT_ROW
The current row number
Field Value:
7

TR_CURRENT_TILE_HEIGHT

public static final int TR_CURRENT_TILE_HEIGHT
The height of the current tile
Field Value:
10

TR_CURRENT_TILE_WIDTH

public static final int TR_CURRENT_TILE_WIDTH
The width of the current tile
Field Value:
9

TR_IMAGE_HEIGHT

public static final int TR_IMAGE_HEIGHT
The height of the final image
Field Value:
4

TR_IMAGE_WIDTH

public static final int TR_IMAGE_WIDTH
The width of the final image
Field Value:
3

TR_ROWS

public static final int TR_ROWS
The number of rows of tiles
Field Value:
5

TR_ROW_ORDER

public static final int TR_ROW_ORDER
The order that the rows are traversed
Field Value:
11

TR_TILE_BORDER

public static final int TR_TILE_BORDER
The width of the border around the tiles
Field Value:
2

TR_TILE_HEIGHT

public static final int TR_TILE_HEIGHT
The height of a tile
Field Value:
1

TR_TILE_WIDTH

public static final int TR_TILE_WIDTH
The width of a tile
Field Value:
0

TR_TOP_TO_BOTTOM

public static final int TR_TOP_TO_BOTTOM
Indicates we are traversing rows from the top to the bottom
Field Value:
1

Constructor Details

TileRenderer

public TileRenderer()
Creates a new TileRenderer object

Method Details

beginTile

public void beginTile(GL gl)
Begins rendering a tile. The projection matrix stack should be left alone after calling this
Parameters:
gl - The gl context

endTile

public boolean endTile(GL gl)
Must be called after rendering the scene
Parameters:
gl - the gl context
Returns:
true if there are more tiles to be rendered, false if the final image is complete

getParam

public int getParam(int param)
Gets the parameters of this TileRenderer object
Parameters:
param - The parameter that is to be retrieved
Returns:
the value of the parameter

setImageBuffer

public void setImageBuffer(int format,
                           int type,
                           Buffer image)
Sets the buffer in which to store the final image
Parameters:
format - Interpreted as in glReadPixels
type - Interpreted as in glReadPixels
image - the buffer itself, must be large enough to hold the final image

setImageSize

public void setImageSize(int width,
                         int height)
Sets the desired size of the final image
Parameters:
width - The width of the final image
height - The height of the final image

setRowOrder

public void setRowOrder(int order)
Sets the order of row traversal
Parameters:
order - The row traversal order, must be eitherTR_TOP_TO_BOTTOM or TR_BOTTOM_TO_TOP

setTileBuffer

public void setTileBuffer(int format,
                          int type,
                          Buffer image)
Specify a buffer the tiles to be copied to. This is not necessary for the creation of the final image, but useful if you want to inspect each tile in turn.
Parameters:
format - Interpreted as in glReadPixels
type - Interpreted as in glReadPixels
image - The buffer itself. Must be large enough to contain a tile, minus any borders

setTileSize

public 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 )
Parameters:
width - The width of the tiles. Must not be larger than the GL context
height - The height of the tiles. Must not be larger than the GL context
border - The width of the borders on each tile. This is needed to avoid artifacts when rendering lines or points with thickness > 1.

trFrustum

public void trFrustum(double left,
                      double right,
                      double bottom,
                      double top,
                      double zNear,
                      double zFar)
Sets the perspective projection frustrum. Must be called before rendering the first tile
Parameters:
left - As in glFrustrum
right - As in glFrustrum
bottom - As in glFrustrum
top - As in glFrustrum
zNear - As in glFrustrum
zFar - As in glFrustrum

trOrtho

public void trOrtho(double left,
                    double right,
                    double bottom,
                    double top,
                    double zNear,
                    double zFar)
Sets the context to use an orthographic projection. Must be called before rendering the first tile
Parameters:
left - As in glOrtho
right - As in glOrtho
bottom - As in glOrtho
top - As in glOrtho
zNear - As in glOrtho
zFar - As in glOrtho

trPerspective

public void trPerspective(double fovy,
                          double aspect,
                          double zNear,
                          double zFar)
Convenient way to specify a perspective projection
Parameters:
fovy - As in gluPerspective
aspect - As in gluPerspective
zNear - As in gluPerspective
zFar - As in gluPerspective

trRasterPos3f

public void trRasterPos3f(float x,
                          float y,
                          float z,
                          GL gl,
                          GLU glu)
Tile rendering causes problems with using glRasterPos3f, so you should use this replacement instead
Parameters:
x - As in glRasterPos3f
y - As in glRasterPos3f
z - As in glRasterPos3f
gl - The gl context
glu - A GLU object

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