com.metsci.glimpse.support.texture
Class TextureProjected2D

java.lang.Object
  extended by com.metsci.glimpse.support.texture.TextureProjected2D
All Implemented Interfaces:
DrawableTexture, Texture
Direct Known Subclasses:
ByteTextureProjected2D, FloatTextureProjected2D, ShortTextureProjected2D

public abstract class TextureProjected2D
extends java.lang.Object
implements DrawableTexture


Field Summary
static int BYTES_PER_FLOAT
           
static int NUM_DIMENSIONS
           
static int VERTICES_PER_QUAD
           
 
Constructor Summary
TextureProjected2D(int dataSizeX, int dataSizeY, boolean useVertexZCoord)
           
 
Method Summary
 void dispose(javax.media.opengl.GLContext context)
          Disposes all Java heap and GPU resources associated with this texture.
 void draw(javax.media.opengl.GL gl, int texUnit)
           
 double getDataValue(double coordX, double coordY)
           
 float getDataValue(int indexX, int indexY)
           
 int getDimensionSize(int n)
          Given a dimension index (0, 1, or 2) returns the number of data elements in the texture along that dimension.
static int getMaxGLTextureSize(javax.media.opengl.GL gl)
           
 int getNumDimension()
          Returns whether the texture is a 1-dimensional, 2-dimensional, or 3-dimensional texture.
 Projection getProjection()
           
 boolean isDirty()
          Indicates whether makeDirty() has been called.
 boolean isResident(javax.media.opengl.GL gl)
          OpenGL implementations may swap store a "working set" of textures in a very fast cache of texture memory.
 void makeDirty()
          Most Texture implementations are backed by a buffer on the heap which acts as a staging area for data changes to the texture.
 void makeProjectionDirty()
           
 boolean prepare(javax.media.opengl.GL gl, int texUnit)
          Allocates space for the texture in GPU texture memory (once, if this is the first time that prepare( GL, int) has been called), copies texture data from the heap into GPU memory (if isDirty() is true).
 void resize(int dataSizeX, int dataSizeY)
          Resizes this two dimensional texture to the given new size.
 void setProjection(Projection projection)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_DIMENSIONS

public static final int NUM_DIMENSIONS
See Also:
Constant Field Values

VERTICES_PER_QUAD

public static final int VERTICES_PER_QUAD
See Also:
Constant Field Values

BYTES_PER_FLOAT

public static final int BYTES_PER_FLOAT
See Also:
Constant Field Values
Constructor Detail

TextureProjected2D

public TextureProjected2D(int dataSizeX,
                          int dataSizeY,
                          boolean useVertexZCoord)
Method Detail

getDataValue

public double getDataValue(double coordX,
                           double coordY)

getDataValue

public float getDataValue(int indexX,
                          int indexY)

makeProjectionDirty

public void makeProjectionDirty()

makeDirty

public void makeDirty()
Description copied from interface: Texture
Most Texture implementations are backed by a buffer on the heap which acts as a staging area for data changes to the texture. Calling makeDirty() indicates that the contents of this buffer has changed and the new data should be copied to the GPU.

Specified by:
makeDirty in interface Texture

isDirty

public boolean isDirty()
Description copied from interface: Texture
Indicates whether makeDirty() has been called. Once makeDirty() is called, isDirty() will return true until prepare( GL, int ) is called and the tecture data is copied to the GPU.

Specified by:
isDirty in interface Texture
Returns:
whether the cached texture data has changed

getNumDimension

public int getNumDimension()
Description copied from interface: Texture
Returns whether the texture is a 1-dimensional, 2-dimensional, or 3-dimensional texture.

Specified by:
getNumDimension in interface Texture
Returns:
1, 2, or 3 depending on the dimension of the texture

getDimensionSize

public int getDimensionSize(int n)
Description copied from interface: Texture
Given a dimension index (0, 1, or 2) returns the number of data elements in the texture along that dimension.

Specified by:
getDimensionSize in interface Texture
Parameters:
n - the texture dimension to query
Returns:
the size of the queried dimension

prepare

public boolean prepare(javax.media.opengl.GL gl,
                       int texUnit)
Description copied from interface: Texture
Allocates space for the texture in GPU texture memory (once, if this is the first time that prepare( GL, int) has been called), copies texture data from the heap into GPU memory (if isDirty() is true). This texture is then made active on the provided texture unit (using glActiveTexture()) and bound as the current GL_TEXTURE_1D, GL_TEXTURE_2D, or GL_TEXTURE_3D as appropriate based on getNumDimension(). Once this is complete, the texture is ready to be used by a GlimpsePainter.

Specified by:
prepare in interface Texture
Parameters:
gl - a GL handle for the active GLContext
texUnit - the texture unit to bind to this texture
Returns:
whether the preparation succeeded

draw

public void draw(javax.media.opengl.GL gl,
                 int texUnit)
Specified by:
draw in interface DrawableTexture

dispose

public void dispose(javax.media.opengl.GLContext context)
Description copied from interface: Texture
Disposes all Java heap and GPU resources associated with this texture.

Specified by:
dispose in interface Texture
Parameters:
context - the active GLContext

getMaxGLTextureSize

public static int getMaxGLTextureSize(javax.media.opengl.GL gl)

isResident

public boolean isResident(javax.media.opengl.GL gl)
Description copied from interface: Texture
OpenGL implementations may swap store a "working set" of textures in a very fast cache of texture memory. Other textures are swapped out and may take longer to access and display. Calling isResident( GL ) indicates whether this texture is resident in texture memory.

Specified by:
isResident in interface Texture
Parameters:
gl - a GL handle for the active GLContext
Returns:
whether this texture is resident in texture memory

resize

public void resize(int dataSizeX,
                   int dataSizeY)
Resizes this two dimensional texture to the given new size. This deallocates any data stored on the graphics card and dirties the texture. If the texture size has been made larger, setData( ) or mutate( ) should be used to provide data for the new larger sections of the data. The dimensions of the data array argument to set data should be float[dataSizeX][dataSizeY].

Parameters:
dataSizeX - the number of texture elements in the 1st, or x, dimension
dataSizeY - the number of texture elements in the 2nd, or y, dimension

setProjection

public void setProjection(Projection projection)

getProjection

public Projection getProjection()


Copyright © 2012 Metron, Inc.. All Rights Reserved.