Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class Texture2D

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.Texture
              extended by org.j3d.aviatrix3d.Texture2D
All Implemented Interfaces:
java.lang.Comparable, MultipassTextureDestination, DeletableRenderable, ObjectRenderable, Renderable, TransparentObjectRenderable, TransparentRenderable

public class Texture2D
extends Texture
implements MultipassTextureDestination

Describes the 2D texture that can be applied to an object.

This texture supports using multipass rendering as a source. By default the read buffer is the back buffer. Copy offsets are set to zero.

For the purposes of state sorting, the multipass data is not considered.

Version:
$Revision: 1.45 $
Author:
Justin Couch, Alan Hudson

Field Summary
protected  int boundaryModeT
          The boundary mode S value
protected  int height
          The height of the main texture.
protected  int mpNumSources
          The current number of mp sources defined
protected  int[][] mpOffsets
          The offset for the multipass copy update per-mipmap.
protected  int mpReadBuffer
          The buffer that multipass source should read from
 
Fields inherited from class org.j3d.aviatrix3d.Texture
ANISOTROPIC_MODE_NONE, ANISOTROPIC_MODE_SINGLE, anisotropicDegree, anisotropicMode, BM_CLAMP, BM_CLAMP_TO_BOUNDARY, BM_CLAMP_TO_EDGE, BM_MIRRORED_REPEAT, BM_WRAP, borderColor, boundaryModeS, COMPARE_FUNCTION_GEQUAL, COMPARE_FUNCTION_LEQUAL, COMPARE_MODE_NONE, COMPARE_MODE_R2TEX, compareFunction, compareMode, depthComponentMode, format, FORMAT_ALPHA, FORMAT_DEPTH_COMPONENT, FORMAT_INTENSITY, FORMAT_INTENSITY_ALPHA, FORMAT_LUMINANCE, FORMAT_LUMINANCE_ALPHA, FORMAT_RGB, FORMAT_RGBA, GENERATE_MIPMAP, GENERATE_MIPMAP_DONT_CARE, GENERATE_MIPMAP_FASTEST, GENERATE_MIPMAP_HINT, GENERATE_MIPMAP_NICEST, generateMipMap, generateMipMapHint, imageChanged, magFilter, MAGFILTER_BASE_LEVEL_LINEAR, MAGFILTER_BASE_LEVEL_POINT, MAGFILTER_FASTEST, MAGFILTER_LINEAR_DETAIL, MAGFILTER_LINEAR_DETAIL_ALPHA, MAGFILTER_LINEAR_DETAIL_RGB, MAGFILTER_NICEST, minFilter, MINFILTER_BASE_LEVEL_LINEAR, MINFILTER_BASE_LEVEL_POINT, MINFILTER_FASTEST, MINFILTER_MULTI_LEVEL_LINEAR, MINFILTER_MULTI_LEVEL_POINT, MINFILTER_NICEST, mipMapMode, MODE_BASE_LEVEL, MODE_MIPMAP, numSources, priority, sources, stateChanged, textureIdMap, textureType, UPDATE_BUFFER_ALL, UPDATE_BUFFER_LAST, UPDATE_DISCARD_OVERWRITES, updateManagers, updateStrategy, width
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Constructor Summary
Texture2D()
          Constructs a texture with default values.
Texture2D(int format, TextureComponent2D singleImage)
          Constructs a texture using a single image.
 
Method Summary
 int compareTo(Texture tex)
          Compares this object with the specified object for order.
 boolean equals(Texture tex)
          Compares this object with the specified object to check for equivalence.
 int getBoundaryModeT()
          Get the current boundary handling for the T parameter.
 void getCopyOffset(int imgNum, int level, int[] offsets)
          Get the current copy offset.
 int getHeight()
          Get the height of the texture in pixels.
 void getMultipassSources(MultipassTextureSource[] sources, int[] images)
          Fetch all of the currently specified multipass texture sources in this instance of the class.
 int getReadBuffer(int imgNum)
          Get the current read buffer that is being used.
 int numMultipassSources()
          Check to see how many multipass texture sources are actually set for.
 void postRender(javax.media.opengl.GL gl)
          Restore all openGL state to the given drawable
 void render(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component
 void setBoundaryModeT(int mode)
          Set the boundary handling for the T parameter.
 void setCopyOffset(int imgNum, int level, int xoffset, int yoffset)
          Set the offsets in this texture to use for update the sub image update values.
 void setReadBuffer(int imgNum, int buffer)
          Set the buffer that this texture should read it's input from during the update callback.
 void setSources(int mipMapMode, int format, TextureSource[] texSources, int num)
          Set a new collection of sources for this texture to use.
 void updateMultipassSource(javax.media.opengl.GL gl, int x, int y, int width, int height, int imgNum, int level)
          The multipass source has completed rendering and the implemented class should now copy the image data across now.
 
Methods inherited from class org.j3d.aviatrix3d.Texture
cleanup, compareTo, equals, getAnisotropicFilterDegree, getAnisotropicFilterMode, getBorderColor, getBoundaryModeS, getCompareFunction, getCompareMode, getDepthFormat, getFormat, getGenerateMipMap, getGenerateMipMapHint, getMagFilter, getMinFilter, getPriority, getTextureType, getUpdateStrategy, getWidth, hasTransparency, setAnisotropicFilterDegree, setAnisotropicFilterMode, setBorderColor, setBoundaryModeS, setCompareFunction, setCompareMode, setDepthFormat, setGenerateMipMap, setGenerateMipMapHint, setLive, setMagFilter, setMinFilter, setPriority, setUpdateHandler, setUpdateStrategy
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boundaryModeT

protected int boundaryModeT
The boundary mode S value


height

protected int height
The height of the main texture.


mpReadBuffer

protected int mpReadBuffer
The buffer that multipass source should read from


mpOffsets

protected int[][] mpOffsets
The offset for the multipass copy update per-mipmap.


mpNumSources

protected int mpNumSources
The current number of mp sources defined

Constructor Detail

Texture2D

public Texture2D()
Constructs a texture with default values.


Texture2D

public Texture2D(int format,
                 TextureComponent2D singleImage)
Constructs a texture using a single image. Mipmap mode is derived from the number of levels provided in the component.

Parameters:
format - The format to render the single image as
singleImage - The source image to use
Method Detail

numMultipassSources

public int numMultipassSources()
Check to see how many multipass texture sources are actually set for. this instance of the destination.

Specified by:
numMultipassSources in interface MultipassTextureDestination
Returns:
The number of defined sources >= 0

getMultipassSources

public void getMultipassSources(MultipassTextureSource[] sources,
                                int[] images)
Fetch all of the currently specified multipass texture sources in this instance of the class. The values are copied into the arrays, along with their corresponding image index and level for mipmapping. The array must be at least as long as numMultipassSources().

Specified by:
getMultipassSources in interface MultipassTextureDestination
Parameters:
sources - An array to copy the current sources into
images - The indices of each of the source images

updateMultipassSource

public void updateMultipassSource(javax.media.opengl.GL gl,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  int imgNum,
                                  int level)
The multipass source has completed rendering and the implemented class should now copy the image data across now.

Specified by:
updateMultipassSource in interface MultipassTextureDestination
Parameters:
gl - The gl context to draw with
x - The x offset in pixels to start the copy from
y - The y offset in pixels to start the copy from
width - The width in pixels of the texture that was rendered
height - The height in pixels of the texture that was rendered
imgNum - The index of the texture source to copy to
level - The mipmap level that this corresponds to

setReadBuffer

public void setReadBuffer(int imgNum,
                          int buffer)
                   throws InvalidWriteTimingException
Set the buffer that this texture should read it's input from during the update callback. For 2D textures the image number is ignored.

Specified by:
setReadBuffer in interface MultipassTextureDestination
Parameters:
imgNum - The index of the image that this offset applies to
buffer - The identifier of the buffer to read from
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getReadBuffer

public int getReadBuffer(int imgNum)
Get the current read buffer that is being used. For 2D textures the image number is ignored.

Specified by:
getReadBuffer in interface MultipassTextureDestination
Parameters:
imgNum - The index of the image that this offset applies to
Returns:
One of the buffer indicies.

setCopyOffset

public void setCopyOffset(int imgNum,
                          int level,
                          int xoffset,
                          int yoffset)
                   throws InvalidWriteTimingException
Set the offsets in this texture to use for update the sub image update values. For 2D textures the image number is ignored.

Specified by:
setCopyOffset in interface MultipassTextureDestination
Parameters:
imgNum - The index of the image that this offset applies to
xoffset - The x offset in pixels to start the copy at
yoffset - The y offset in pixels to start the copy at
level - The mipmap level that this corresponds to
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getCopyOffset

public void getCopyOffset(int imgNum,
                          int level,
                          int[] offsets)
Get the current copy offset. The return values are copied into the user provided array as [xoffset, yoffset]. For 2D textures the image number is ignored.

Specified by:
getCopyOffset in interface MultipassTextureDestination
Parameters:
imgNum - The index of the image that this offset applies to
level - The mipmap level that this corresponds to
offsets - An array to copy the values into

setSources

public void setSources(int mipMapMode,
                       int format,
                       TextureSource[] texSources,
                       int num)
                throws InvalidWriteTimingException
Set a new collection of sources for this texture to use.

Overrides:
setSources in class Texture
Parameters:
mipMapMode - Flag stating the type of texture mode to use
format - Image format to use for grayscale sources
texSources - The source data to use, single for base level
num - The valid number of sources to use from the array
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

render

public void render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component

Specified by:
render in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable

Specified by:
postRender in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

compareTo

public int compareTo(Texture tex)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Derived instances should override this to add texture-specific extensions.

Overrides:
compareTo in class Texture
Parameters:
tex - The texture instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(Texture tex)
Compares this object with the specified object to check for equivalence.

Overrides:
equals in class Texture
Parameters:
tex - The texture instance to be compared
Returns:
true if the objects represent identical values

setBoundaryModeT

public void setBoundaryModeT(int mode)
                      throws InvalidWriteTimingException
Set the boundary handling for the T parameter.

Parameters:
mode - The new mode.
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getBoundaryModeT

public int getBoundaryModeT()
Get the current boundary handling for the T parameter.

Returns:
The current mode.

getHeight

public int getHeight()
Get the height of the texture in pixels. If no image is set, this returns -1.

Returns:
a number >= -1

Aviatrix3D
2.1.0

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