37package com.jogamp.opengl.util;
39import com.jogamp.nativewindow.util.Dimension;
40import com.jogamp.nativewindow.util.DimensionImmutable;
41import com.jogamp.opengl.GL;
42import com.jogamp.opengl.GL2ES3;
43import com.jogamp.opengl.GLAutoDrawable;
44import com.jogamp.opengl.GLCapabilitiesImmutable;
45import com.jogamp.opengl.GLDrawable;
46import com.jogamp.opengl.GLEventListener;
47import com.jogamp.opengl.GLException;
48import jogamp.opengl.Debug;
117 static final boolean DEBUG = Debug.debug(
"TileRenderer");
177 int tileX,
int tileY,
int tileWidth,
int tileHeight,
178 int imageWidth,
int imageHeight);
230 private final String hashStr(
final Object o) {
231 final int h =
null != o ? o.hashCode() : 0;
232 return "0x"+Integer.toHexString(h);
237 public StringBuilder
toString(
final StringBuilder sb) {
238 final int gladListenerCount =
null !=
listeners ? listeners.length : 0;
243 sb.append(
", isSetup "+
isSetup());
248 final StringBuilder sb =
new StringBuilder();
249 return getClass().getSimpleName()+
263 public abstract int getParam(
int pname)
throws IllegalArgumentException;
275 System.err.println(
"TileRenderer: tile-buffer "+
tileBuffer);
303 System.err.println(
"TileRenderer: image-buffer "+
imageBuffer);
312 throw new GLException(
"Using image-buffer w/ inssufficient GL context: "+gl.getContext().getGLVersion()+
", "+gl.getGLProfile());
333 public abstract boolean eot();
469 if(
null != this.glad ) {
470 throw new IllegalStateException(
"GLAutoDrawable already attached");
477 for(
int i=0; i<aSz; i++) {
489 System.err.println(
"TileRenderer.attach["+i+
"]: isInit "+
listenersInit[i]+
", isTRN "+trn+
", "+
listeners[i].getClass().getName());
497 System.err.println(
"TileRenderer: attached: "+
glad);
526 for(
int i=0; i<aSz; i++) {
536 System.err.println(
"TileRenderer: detached: "+
glad);
564 public final void display() throws IllegalStateException {
566 throw new IllegalStateException(
"No GLAutoDrawable attached");
580 for(
int i=0; i<aSz; i++) {
582 if( !
listenersInit[i] && l instanceof TileRendererListener ) {
592 public void dispose(
final GLAutoDrawable drawable) {
597 for(
int i=0; i<aSz; i++) {
605 public void display(
final GLAutoDrawable drawable) {
612 System.err.println(
"TileRenderer.glel.display: !setup: "+
TileRendererBase.this);
618 System.err.println(
"TileRenderer.glel.display: EOT: "+
TileRendererBase.this);
622 final GL gl = drawable.getGL();
627 for(
int i=0; i<aSz; i++) {
629 if( l instanceof TileRendererListener ) {
630 final TileRendererListener tl = (TileRendererListener)l;
631 if(
null == tileRenderer || 0 == tileRenderer.getCurrentTile() ) {
648 if(
null == tileRenderer || tileRenderer.
eot() ) {
649 for(
int i=0; i<aSz; i++) {
651 if( l instanceof TileRendererListener ) {
662 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
final void set(final int width, final int height)
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Providing utility functions dealing w/ GLDrawables, GLAutoDrawable and their GLEventListener.
static final boolean swapBuffersBeforeRead(final GLCapabilitiesImmutable chosenCaps)
Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.
OpenGL pixel data buffer, allowing user to provide buffers via their GLPixelBufferProvider implementa...
Utility to safely set and restore the PACK and UNPACK pixel storage mode, regardless of the GLProfile...
A fairly direct port of Brian Paul's tile rendering library, found at http://www.mesa3d....
final void setGLEventListener(final GLEventListener preTile, final GLEventListener postTile)
Set GLEventListener for pre- and post operations when used w/ attachAutoDrawable(GLAutoDrawable) for ...
final void setTileBuffer(final GLPixelBuffer buffer)
Specify a buffer the tiles to be copied to.
boolean gladRequiresPreSwap
final GLAutoDrawable getAttachedDrawable()
Returns a previously attached GLAutoDrawable, null if none is attached.
abstract boolean eot()
Returns true if end of tiling has been reached, otherwise false.
abstract int getParam(int pname)
Gets the parameters of this TileRenderer object.
GLPixelBuffer imageBuffer
final void setImageBuffer(final GLPixelBuffer buffer)
Sets the buffer in which to store the final image.
static final int TR_CURRENT_TILE_WIDTH
The width of the current tile.
boolean gladAutoSwapBufferMode
final Dimension imageSize
StringBuilder tileDetails(final StringBuilder sb)
final boolean reqPreSwapBuffers(final GLCapabilitiesImmutable chosenCaps)
Determines whether the chosen GLCapabilitiesImmutable requires a pre-swap-buffers before accessing th...
static final int TR_IMAGE_WIDTH
The width of the final image.
abstract void endTile(GL gl)
Must be called after rendering the scene, see beginTile(GL).
GLEventListener glEventListenerPost
abstract void reset()
Method resets implementation's internal state to start of tiling as required for beginTile(GL) if end...
final GLPixelStorageModes psm
final void detachAutoDrawable()
Detaches the given GLAutoDrawable from this tile renderer.
StringBuilder toString(final StringBuilder sb)
abstract void beginTile(GL gl)
Begins rendering a tile.
static final int TR_CURRENT_TILE_HEIGHT
The height of the current tile.
final GLPixelBuffer getImageBuffer()
static final int TR_CURRENT_TILE_X_POS
The x-pos of the current tile.
GLEventListener[] listeners
final void display()
Rendering one tile, by simply calling GLAutoDrawable#display().
final void attachAutoDrawable(final GLAutoDrawable glad)
Attaches the given GLAutoDrawable to this tile renderer.
final DimensionImmutable getImageSize()
abstract boolean isSetup()
Returns true if this instance is setup properly, i.e.
GLEventListener glEventListenerPre
void setImageSize(final int width, final int height)
Sets the desired size of the final image.
final GLPixelBuffer getTileBuffer()
static final int TR_CURRENT_TILE_Y_POS
The y-pos of the current tile.
static final int TR_IMAGE_HEIGHT
The height of the final image.
A fairly direct port of Brian Paul's tile rendering library, found at http://www.mesa3d....
final boolean eot()
Returns true if end of tiling has been reached, otherwise false.end of tiling criteria is implementat...
Immutable Dimension Interface, consisting of it's read only components:
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GLEventListener getGLEventListener(int index)
Returns the GLEventListener at the given index of this drawable queue.
void setGLEventListenerInitState(GLEventListener listener, boolean initialized)
Sets the given listener's initialized state.
boolean getAutoSwapBufferMode()
Indicates whether automatic buffer swapping is enabled for this drawable.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
int getGLEventListenerCount()
Returns the number of GLEventListener of this drawable queue.
GLEventListener removeGLEventListener(GLEventListener listener)
Removes the given listener from this drawable queue.
boolean getGLEventListenerInitState(GLEventListener listener)
Retrieves whether the given listener is initialized or not.
void setAutoSwapBufferMode(boolean enable)
Enables or disables automatic buffer swapping for this drawable.
Specifies an immutable set of OpenGL capabilities.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
void swapBuffers()
Swaps the front and back buffers of this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void dispose(GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
Called by the drawable during the first repaint after the component has been resized.
Listener for tile renderer events, intended to extend GLEventListener implementations,...
void reshapeTile(TileRendererBase tr, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight)
Called by the TileRendererBase during tile-rendering via an attached GLAutoDrawable's GLAutoDrawable#...
void removeTileRendererNotify(TileRendererBase tr)
The owning GLAutoDrawable is detached from the given TileRendererBase instance.
void addTileRendererNotify(TileRendererBase tr)
The owning GLAutoDrawable is attached to the given TileRendererBase instance.
void endTileRendering(TileRendererBase tr)
Called by the TileRenderer during tile-rendering after TileRendererBase#endTile(GL) and GLAutoDrawabl...
void startTileRendering(TileRendererBase tr)
Called by the TileRendererBase during tile-rendering after TileRendererBase#beginTile(GL) and before ...