JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.opengl.util.TileRendererBase Class Referenceabstract

A fairly direct port of Brian Paul's tile rendering library, found at http://www.mesa3d.org/brianp/TR.html . More...

Inheritance diagram for com.jogamp.opengl.util.TileRendererBase:
Collaboration diagram for com.jogamp.opengl.util.TileRendererBase:

Classes

interface  TileRendererListener
 Listener for tile renderer events, intended to extend GLEventListener implementations, enabling tile rendering via TileRendererBase#attachAutoDrawable(GLAutoDrawable). More...
 

Public Member Functions

StringBuilder toString (final StringBuilder sb)
 
String toString ()
 
abstract int getParam (int pname) throws IllegalArgumentException
 Gets the parameters of this TileRenderer object. More...
 
final void setTileBuffer (final GLPixelBuffer buffer)
 Specify a buffer the tiles to be copied to. More...
 
final GLPixelBuffer getTileBuffer ()
 
void setImageSize (final int width, final int height)
 Sets the desired size of the final image. More...
 
final DimensionImmutable getImageSize ()
 
final void setImageBuffer (final GLPixelBuffer buffer)
 Sets the buffer in which to store the final image. More...
 
final GLPixelBuffer getImageBuffer ()
 
abstract boolean isSetup ()
 Returns true if this instance is setup properly, i.e. More...
 
abstract boolean eot ()
 Returns true if end of tiling has been reached, otherwise false. More...
 
abstract void reset ()
 Method resets implementation's internal state to start of tiling as required for beginTile(GL) if end of tiling has been reached. More...
 
abstract void beginTile (GL gl) throws IllegalStateException, GLException
 Begins rendering a tile. More...
 
abstract void endTile (GL gl) throws IllegalStateException, GLException
 Must be called after rendering the scene, see beginTile(GL). More...
 
final boolean reqPreSwapBuffers (final GLCapabilitiesImmutable chosenCaps)
 Determines whether the chosen GLCapabilitiesImmutable requires a pre-swap-buffers before accessing the results, i.e. More...
 
final void attachAutoDrawable (final GLAutoDrawable glad) throws IllegalStateException
 Attaches the given GLAutoDrawable to this tile renderer. More...
 
final GLAutoDrawable getAttachedDrawable ()
 Returns a previously attached GLAutoDrawable, null if none is attached. More...
 
final void detachAutoDrawable ()
 Detaches the given GLAutoDrawable from this tile renderer. More...
 
final void setGLEventListener (final GLEventListener preTile, final GLEventListener postTile)
 Set GLEventListener for pre- and post operations when used w/ attachAutoDrawable(GLAutoDrawable) for each GLEventListener callback. More...
 
final void display () throws IllegalStateException
 Rendering one tile, by simply calling GLAutoDrawable#display(). More...
 

Static Public Attributes

static final int TR_IMAGE_WIDTH = 1
 The width of the final image. More...
 
static final int TR_IMAGE_HEIGHT = 2
 The height of the final image. More...
 
static final int TR_CURRENT_TILE_X_POS = 3
 The x-pos of the current tile. More...
 
static final int TR_CURRENT_TILE_Y_POS = 4
 The y-pos of the current tile. More...
 
static final int TR_CURRENT_TILE_WIDTH = 5
 The width of the current tile. More...
 
static final int TR_CURRENT_TILE_HEIGHT = 6
 The height of the current tile. More...
 

Protected Member Functions

StringBuilder tileDetails (final StringBuilder sb)
 
 TileRendererBase ()
 

Protected Attributes

final Dimension imageSize = new Dimension(0, 0)
 
final GLPixelStorageModes psm = new GLPixelStorageModes()
 
GLPixelBuffer imageBuffer
 
GLPixelBuffer tileBuffer
 
boolean beginCalled = false
 
int currentTileXPos
 
int currentTileYPos
 
int currentTileWidth
 
int currentTileHeight
 
GLAutoDrawable glad
 
boolean gladRequiresPreSwap
 
boolean gladAutoSwapBufferMode = true
 
GLEventListener[] listeners
 
boolean[] listenersInit
 
GLEventListener glEventListenerPre = null
 
GLEventListener glEventListenerPost = null
 

Detailed Description

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 GL and GL2ES3, abstracted to suit TileRenderer and RandomTileRenderer.

PMV Matrix Considerations

The PMV matrix needs to be reshaped in user code after calling beginTile(GL), See beginTile(GL).

If attaching to an GLAutoDrawable, the TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int) method is being called after beginTile(GL) for each rendered tile. It's implementation shall reshape the PMV matrix according to beginTile(GL).

GL Profile Requirement

Note that image buffer can only be used in conjunction w/ a GL instance ≥ GL2ES3 passed to beginTile(GL) and endTile(GL).
This is due to setting up the pack row length for an image width != tile-width, which usually is the case.
Hence a GLException is thrown in both methods, if using an image buffer and passing a GL instance < GL2ES3.

Further more, reading back of MSAA buffers is only supported since GL2ES3 since it requires to set the read-buffer.

Author
ryanm, sgothel

Definition at line 91 of file TileRendererBase.java.

Constructor & Destructor Documentation

◆ TileRendererBase()

com.jogamp.opengl.util.TileRendererBase.TileRendererBase ( )
protected

Definition at line 253 of file TileRendererBase.java.

Member Function Documentation

◆ attachAutoDrawable()

final void com.jogamp.opengl.util.TileRendererBase.attachAutoDrawable ( final GLAutoDrawable  glad) throws IllegalStateException

Attaches the given GLAutoDrawable to this tile renderer.

The GLAutoDrawable's original GLEventListener are moved to this tile renderer.

GLEventListeners not implementing TileRendererListener are ignored while tile rendering.

The GLAutoDrawable's auto-swap mode is cached and set to false, since swapBuffers() maybe issued before endTile(GL), see reqPreSwapBuffers(GLCapabilitiesImmutable).

This tile renderer's internal GLEventListener is then added to the attached GLAutoDrawable to handle the tile rendering, replacing the original GLEventListener.
It's display implementations issues:

Consider using setGLEventListener(GLEventListener, GLEventListener) to add pre- and post hooks to be performed on this renderer GLEventListener.
The pre-hook is able to allocate memory and setup parameters, since it's called before beginTile(GL).
The post-hook is able to use the rendering result and can even shutdown tile-rendering, since it's called after endTile(GL).

Call detachAutoDrawable() to remove the attached GLAutoDrawable from this tile renderer and to restore it's original GLEventListener.

Parameters
gladthe GLAutoDrawable to attach.
Exceptions
IllegalStateExceptionif an GLAutoDrawable is already attached
See also
getAttachedDrawable()
detachAutoDrawable()

Definition at line 468 of file TileRendererBase.java.

Here is the call graph for this function:

◆ beginTile()

abstract void com.jogamp.opengl.util.TileRendererBase.beginTile ( GL  gl) throws IllegalStateException, GLException
abstract

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
glThe gl context
Exceptions
IllegalStateExceptionif image-size is undefined, an implementation related setup has not be performed or {@ link eot()} has been reached. See implementing classes.
GLExceptionif image buffer is used but gl instance is < GL2ES3
See also
isSetup()
eot()
reset()

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

◆ detachAutoDrawable()

final void com.jogamp.opengl.util.TileRendererBase.detachAutoDrawable ( )

Detaches the given GLAutoDrawable from this tile renderer.

See also
attachAutoDrawable(GLAutoDrawable)
getAttachedDrawable()

Definition at line 522 of file TileRendererBase.java.

Here is the call graph for this function:

◆ display()

final void com.jogamp.opengl.util.TileRendererBase.display ( ) throws IllegalStateException

Rendering one tile, by simply calling GLAutoDrawable#display().

Exceptions
IllegalStateExceptionif no GLAutoDrawable is attached or imageSize is not set

Definition at line 564 of file TileRendererBase.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTile()

abstract void com.jogamp.opengl.util.TileRendererBase.endTile ( GL  gl) throws IllegalStateException, GLException
abstract

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
glthe gl context
Exceptions
IllegalStateExceptionif beginTile(gl) has not been called
GLExceptionif image buffer is used but gl instance is < GL2ES3

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

◆ eot()

abstract boolean com.jogamp.opengl.util.TileRendererBase.eot ( )
abstract

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.

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

◆ getAttachedDrawable()

final GLAutoDrawable com.jogamp.opengl.util.TileRendererBase.getAttachedDrawable ( )

Returns a previously attached GLAutoDrawable, null if none is attached.

If called from TileRendererListener#addTileRendererNotify(TileRendererBase) or TileRendererListener#removeTileRendererNotify(TileRendererBase), method returns the just attached or soon to be detached GLAutoDrawable.

See also
attachAutoDrawable(GLAutoDrawable)
detachAutoDrawable()

Definition at line 513 of file TileRendererBase.java.

Here is the caller graph for this function:

◆ getImageBuffer()

final GLPixelBuffer com.jogamp.opengl.util.TileRendererBase.getImageBuffer ( )
See also
setImageBuffer(GLPixelBuffer)

Definition at line 308 of file TileRendererBase.java.

Here is the caller graph for this function:

◆ getImageSize()

final DimensionImmutable com.jogamp.opengl.util.TileRendererBase.getImageSize ( )
See also
setImageSize(int, int)

Definition at line 293 of file TileRendererBase.java.

◆ getParam()

abstract int com.jogamp.opengl.util.TileRendererBase.getParam ( int  pname) throws IllegalArgumentException
abstract

Gets the parameters of this TileRenderer object.

Parameters
pnameThe parameter name that is to be retrieved
Returns
the value of the parameter
Exceptions
IllegalArgumentExceptionif pname is not handled

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

◆ getTileBuffer()

final GLPixelBuffer com.jogamp.opengl.util.TileRendererBase.getTileBuffer ( )
See also
setTileBuffer(GLPixelBuffer)

Definition at line 280 of file TileRendererBase.java.

◆ isSetup()

abstract boolean com.jogamp.opengl.util.TileRendererBase.isSetup ( )
abstract

Returns true if this instance is setup properly, i.e.

setImageSize(int, int) .., and ready for beginTile(GL). Otherwise returns false.

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

Here is the caller graph for this function:

◆ reqPreSwapBuffers()

final boolean com.jogamp.opengl.util.TileRendererBase.reqPreSwapBuffers ( final GLCapabilitiesImmutable  chosenCaps)

Determines whether the chosen GLCapabilitiesImmutable requires a pre-swap-buffers before accessing the results, i.e.

before endTile(GL).

See GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable).

Definition at line 417 of file TileRendererBase.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

abstract void com.jogamp.opengl.util.TileRendererBase.reset ( )
abstract

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.

Reimplemented in com.jogamp.opengl.util.RandomTileRenderer, and com.jogamp.opengl.util.TileRenderer.

◆ setGLEventListener()

final void com.jogamp.opengl.util.TileRendererBase.setGLEventListener ( final GLEventListener  preTile,
final GLEventListener  postTile 
)

Set GLEventListener for pre- and post operations when used w/ attachAutoDrawable(GLAutoDrawable) for each GLEventListener callback.

Parameters
preTilethe pre operations
postTilethe post operations

Definition at line 553 of file TileRendererBase.java.

◆ setImageBuffer()

final void com.jogamp.opengl.util.TileRendererBase.setImageBuffer ( final GLPixelBuffer  buffer)

Sets the buffer in which to store the final image.

Parameters
bufferthe buffer itself, must be large enough to hold the final image

Definition at line 300 of file TileRendererBase.java.

Here is the caller graph for this function:

◆ setImageSize()

void com.jogamp.opengl.util.TileRendererBase.setImageSize ( final int  width,
final int  height 
)

Sets the desired size of the final image.

Parameters
widthThe width of the final image
heightThe height of the final image

Reimplemented in com.jogamp.opengl.util.TileRenderer.

Definition at line 288 of file TileRendererBase.java.

Here is the call graph for this function:

◆ setTileBuffer()

final void com.jogamp.opengl.util.TileRendererBase.setTileBuffer ( final GLPixelBuffer  buffer)

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
bufferThe buffer itself. Must be large enough to contain a random tile

Definition at line 272 of file TileRendererBase.java.

◆ tileDetails()

StringBuilder com.jogamp.opengl.util.TileRendererBase.tileDetails ( final StringBuilder  sb)
protected

Reimplemented in com.jogamp.opengl.util.TileRenderer.

Definition at line 234 of file TileRendererBase.java.

Here is the caller graph for this function:

◆ toString() [1/2]

String com.jogamp.opengl.util.TileRendererBase.toString ( )

Definition at line 247 of file TileRendererBase.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString() [2/2]

StringBuilder com.jogamp.opengl.util.TileRendererBase.toString ( final StringBuilder  sb)

Definition at line 237 of file TileRendererBase.java.

Here is the call graph for this function:

Member Data Documentation

◆ beginCalled

boolean com.jogamp.opengl.util.TileRendererBase.beginCalled = false
protected

Definition at line 217 of file TileRendererBase.java.

◆ currentTileHeight

int com.jogamp.opengl.util.TileRendererBase.currentTileHeight
protected

Definition at line 221 of file TileRendererBase.java.

◆ currentTileWidth

int com.jogamp.opengl.util.TileRendererBase.currentTileWidth
protected

Definition at line 220 of file TileRendererBase.java.

◆ currentTileXPos

int com.jogamp.opengl.util.TileRendererBase.currentTileXPos
protected

Definition at line 218 of file TileRendererBase.java.

◆ currentTileYPos

int com.jogamp.opengl.util.TileRendererBase.currentTileYPos
protected

Definition at line 219 of file TileRendererBase.java.

◆ glad

GLAutoDrawable com.jogamp.opengl.util.TileRendererBase.glad
protected

Definition at line 222 of file TileRendererBase.java.

◆ gladAutoSwapBufferMode

boolean com.jogamp.opengl.util.TileRendererBase.gladAutoSwapBufferMode = true
protected

Definition at line 224 of file TileRendererBase.java.

◆ gladRequiresPreSwap

boolean com.jogamp.opengl.util.TileRendererBase.gladRequiresPreSwap
protected

Definition at line 223 of file TileRendererBase.java.

◆ glEventListenerPost

GLEventListener com.jogamp.opengl.util.TileRendererBase.glEventListenerPost = null
protected

Definition at line 228 of file TileRendererBase.java.

◆ glEventListenerPre

GLEventListener com.jogamp.opengl.util.TileRendererBase.glEventListenerPre = null
protected

Definition at line 227 of file TileRendererBase.java.

◆ imageBuffer

GLPixelBuffer com.jogamp.opengl.util.TileRendererBase.imageBuffer
protected

Definition at line 215 of file TileRendererBase.java.

◆ imageSize

final Dimension com.jogamp.opengl.util.TileRendererBase.imageSize = new Dimension(0, 0)
protected

Definition at line 213 of file TileRendererBase.java.

◆ listeners

GLEventListener [] com.jogamp.opengl.util.TileRendererBase.listeners
protected

Definition at line 225 of file TileRendererBase.java.

◆ listenersInit

boolean [] com.jogamp.opengl.util.TileRendererBase.listenersInit
protected

Definition at line 226 of file TileRendererBase.java.

◆ psm

final GLPixelStorageModes com.jogamp.opengl.util.TileRendererBase.psm = new GLPixelStorageModes()
protected

Definition at line 214 of file TileRendererBase.java.

◆ tileBuffer

GLPixelBuffer com.jogamp.opengl.util.TileRendererBase.tileBuffer
protected

Definition at line 216 of file TileRendererBase.java.

◆ TR_CURRENT_TILE_HEIGHT

final int com.jogamp.opengl.util.TileRendererBase.TR_CURRENT_TILE_HEIGHT = 6
static

The height of the current tile.

See getParam(int).

Definition at line 115 of file TileRendererBase.java.

◆ TR_CURRENT_TILE_WIDTH

final int com.jogamp.opengl.util.TileRendererBase.TR_CURRENT_TILE_WIDTH = 5
static

The width of the current tile.

See getParam(int).

Definition at line 111 of file TileRendererBase.java.

◆ TR_CURRENT_TILE_X_POS

final int com.jogamp.opengl.util.TileRendererBase.TR_CURRENT_TILE_X_POS = 3
static

The x-pos of the current tile.

See getParam(int).

Definition at line 103 of file TileRendererBase.java.

◆ TR_CURRENT_TILE_Y_POS

final int com.jogamp.opengl.util.TileRendererBase.TR_CURRENT_TILE_Y_POS = 4
static

The y-pos of the current tile.

See getParam(int).

Definition at line 107 of file TileRendererBase.java.

◆ TR_IMAGE_HEIGHT

final int com.jogamp.opengl.util.TileRendererBase.TR_IMAGE_HEIGHT = 2
static

The height of the final image.

See getParam(int).

Definition at line 99 of file TileRendererBase.java.

◆ TR_IMAGE_WIDTH

final int com.jogamp.opengl.util.TileRendererBase.TR_IMAGE_WIDTH = 1
static

The width of the final image.

See getParam(int).

Definition at line 95 of file TileRendererBase.java.


The documentation for this class was generated from the following file: