Aviatrix3D
2.1.0

org.j3d.aviatrix3d.iutil
Class TextureUpdateStateManager

java.lang.Object
  extended by org.j3d.aviatrix3d.iutil.TextureUpdateStateManager
All Implemented Interfaces:
SubTextureUpdateListener

public class TextureUpdateStateManager
extends java.lang.Object
implements SubTextureUpdateListener

Class that handles all of the update state messaging in a cross between a listener and a traditional HashMap.

Since the state manager manages update requests keyed by GL context, if an update is recieved before the context has been registered with the map, then they will disappear. This is particularly important if you are attempting to make texture updates prior to the first frame rendering or if an update is called on the first call of the app update observer.

Version:
$Revision: 1.5 $
Author:
Justin Couch

Field Summary
static int UPDATE_BUFFER_ALL
          All sub image updates should be buffered until the next chance to update.
static int UPDATE_BUFFER_LAST
          Each update should discard any previous updates recieved.
static int UPDATE_DISCARD_OVERWRITES
          Each update should check to see whether the area of this update overlaps completely that of any other buffered updates.
 
Constructor Summary
TextureUpdateStateManager(int strategy)
          Create a new state manager using the given strategy.
TextureUpdateStateManager(int strategy, int initialCapacity, float loadFactor)
          Create a new instance of the updater.
 
Method Summary
 void addContext(javax.media.opengl.GL gl)
          Register a new context instance with this manager.
 void clear()
          Clears this manager so that it contains no keys.
 void clearPendingUpdates()
          Convenience method to empty the current pending updates list and drop the values into the cache.
 int getNumUpdatesPending(javax.media.opengl.GL gl)
          Returns the number of updates that are pending for a given context.
 TextureUpdateData[] getUpdatesAndClear(javax.media.opengl.GL gl)
          Returns an array holding all the pending updates for the given GL context and resets the number pending back to 0.
 boolean isEmpty()
          Check to see if if this manager contains no current contexts registered.
 void removeContext(javax.media.opengl.GL gl)
          Removes the context (and its corresponding updates) from the manager.
 void setTextureFormat(int f)
          Set the new texture format to use.
 void setUpdateStrategy(int strategy)
          Change the update strategy to use.
 int size()
          Returns the number of contexts current registered in this manager.
 void textureUpdated(int x, int y, int z, int width, int height, int depth, int level, byte[] pixels)
          Notification that the texture has updated a section of the texture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATE_BUFFER_ALL

public static final int UPDATE_BUFFER_ALL
All sub image updates should be buffered until the next chance to update. Best for when you are only updating small sections of the screen.

See Also:
Constant Field Values

UPDATE_BUFFER_LAST

public static final int UPDATE_BUFFER_LAST
Each update should discard any previous updates recieved. Best used when you know you'll only be updating one area, overwritting any earlier updates - For example video texturing.

See Also:
Constant Field Values

UPDATE_DISCARD_OVERWRITES

public static final int UPDATE_DISCARD_OVERWRITES
Each update should check to see whether the area of this update overlaps completely that of any other buffered updates. Useful if you're doing scattered region updates where some parts may overlap but others don't.

See Also:
Constant Field Values
Constructor Detail

TextureUpdateStateManager

public TextureUpdateStateManager(int strategy)
Create a new state manager using the given strategy.

Parameters:
strategy - one of the UPDATE_ identifiers

TextureUpdateStateManager

public TextureUpdateStateManager(int strategy,
                                 int initialCapacity,
                                 float loadFactor)
Create a new instance of the updater.

Parameters:
strategy - one of the UPDATE_ identifiers
initialCapacity - the initial capacity of the hashtable.
loadFactor - the load factor of the underlying hashtable.
Method Detail

textureUpdated

public void textureUpdated(int x,
                           int y,
                           int z,
                           int width,
                           int height,
                           int depth,
                           int level,
                           byte[] pixels)
Notification that the texture has updated a section of the texture. This is generic for all textures correctly.

Specified by:
textureUpdated in interface SubTextureUpdateListener
Parameters:
x - The start location x coordinate in texel space
y - The start location y coordinate in texel space
z - The start location z coordinate in texel space
width - The width of the update in texel space
height - The height of the update in texel space
depth - The depth of the update in texel space
level - The mipmap level that changed
pixels - Buffer of the data that has updated

size

public int size()
Returns the number of contexts current registered in this manager.

Returns:
A value >= 0 for the number of valid contexts

isEmpty

public boolean isEmpty()
Check to see if if this manager contains no current contexts registered.

Returns:
true if this manager has size() == 0, false otherwise

setTextureFormat

public void setTextureFormat(int f)
Set the new texture format to use. The format needs be one of the GL.GL_* values, not one of the aviatrix values. This is passed directly to the glSubTexImage() call.

Parameters:
f - The format type to use

setUpdateStrategy

public void setUpdateStrategy(int strategy)
Change the update strategy to use.

Parameters:
strategy - The new update type

getNumUpdatesPending

public int getNumUpdatesPending(javax.media.opengl.GL gl)
Returns the number of updates that are pending for a given context.

Parameters:
gl - The GL context to fetch the update array for
Returns:
A number >= 0

getUpdatesAndClear

public TextureUpdateData[] getUpdatesAndClear(javax.media.opengl.GL gl)
Returns an array holding all the pending updates for the given GL context and resets the number pending back to 0. The array is the internal list and should be treated as read-only data. If the context is unknown to this map, it will return null.

Parameters:
gl - The GL context to fetch the update array for
Returns:
An array to read updates from, or null

addContext

public void addContext(javax.media.opengl.GL gl)
Register a new context instance with this manager.

Parameters:
gl - The GL context to remove as a key

removeContext

public void removeContext(javax.media.opengl.GL gl)
Removes the context (and its corresponding updates) from the manager. This method does nothing if the key is not registered.

Parameters:
gl - The GL context to remove as a key

clear

public void clear()
Clears this manager so that it contains no keys.


clearPendingUpdates

public void clearPendingUpdates()
Convenience method to empty the current pending updates list and drop the values into the cache.


Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org