Class TextureProjected2D
- java.lang.Object
-
- com.metsci.glimpse.core.support.texture.TextureProjected2D
-
- All Implemented Interfaces:
DrawableTexture
,Texture
- Direct Known Subclasses:
ByteTextureProjected2D
,ExternalTextureProjected2D
,FloatTextureProjected2D
,RGBATextureProjected2D
,RGBTextureProjected2D
,ShortTextureProjected2D
public abstract class TextureProjected2D extends Object implements DrawableTexture
-
-
Field Summary
Fields Modifier and Type Field Description static int
BYTES_PER_FLOAT
static int
NUM_DIMENSIONS
static int
VERTICES_PER_QUAD
-
Constructor Summary
Constructors Constructor Description TextureProjected2D(int dataSizeX, int dataSizeY, boolean useVertexZCoord)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
dispose(com.jogamp.opengl.GLContext context)
Disposes all Java heap and GPU resources associated with this texture.void
draw(GlimpseContext context, DrawableTextureProgram program, int texUnit)
void
draw(GlimpseContext context, DrawableTextureProgram program, int texUnit, Collection<TextureUnit<Texture>> multiTextureList)
Draw the texture using the provided program.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.int[]
getHandles()
Returns the OpenGL handle to the texture data.static int
getMaxGLTextureSize(com.jogamp.opengl.GL gl)
int
getNumDimension()
Returns whether the texture is a 1-dimensional, 2-dimensional, or 3-dimensional texture.Projection
getProjection()
boolean
isDirty()
Indicates whethermakeDirty()
has been called.boolean
isResident(com.jogamp.opengl.GL2 gl)
Deprecated.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(GlimpseContext context, int texUnit)
Allocates space for the texture in GPU texture memory (once, if this is the first time thatprepare( GL, int)
has been called), copies texture data from the heap into GPU memory (ifisDirty()
is true).void
resize(int dataSizeX, int dataSizeY)
Resizes this two dimensional texture to the given new size.void
setProjection(Projection projection)
-
-
-
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
-
-
Method Detail
-
getDataValue
public double getDataValue(double coordX, double coordY)
-
getDataValue
public float getDataValue(int indexX, int indexY)
-
makeProjectionDirty
public void makeProjectionDirty()
-
getHandles
public int[] getHandles()
Description copied from interface:Texture
Returns the OpenGL handle to the texture data. Most implementations will return an array with a single value. However, some implementations may split up very large data into multiple OpenGL textures. This method is necessary to support proper handling of multitexturing shaders.- Specified by:
getHandles
in interfaceTexture
-
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. CallingmakeDirty()
indicates that the contents of this buffer has changed and the new data should be copied to the GPU.
-
isDirty
public boolean isDirty()
Description copied from interface:Texture
Indicates whethermakeDirty()
has been called. OncemakeDirty()
is called,isDirty()
will return true untilprepare( GL, int )
is called and the tecture data is copied to the GPU.
-
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 interfaceTexture
- 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 interfaceTexture
- Parameters:
n
- the texture dimension to query- Returns:
- the size of the queried dimension
-
prepare
public boolean prepare(GlimpseContext context, int texUnit)
Description copied from interface:Texture
Allocates space for the texture in GPU texture memory (once, if this is the first time thatprepare( GL, int)
has been called), copies texture data from the heap into GPU memory (ifisDirty()
is true). This texture is then made active on the provided texture unit (usingglActiveTexture()
) and bound as the currentGL_TEXTURE_1D
,GL_TEXTURE_2D
, orGL_TEXTURE_3D
as appropriate based ongetNumDimension()
. Once this is complete, the texture is ready to be used by aGlimpsePainter
.
-
draw
public void draw(GlimpseContext context, DrawableTextureProgram program, int texUnit)
-
draw
public void draw(GlimpseContext context, DrawableTextureProgram program, int texUnit, Collection<TextureUnit<Texture>> multiTextureList)
Description copied from interface:DrawableTexture
Draw the texture using the provided program.- Specified by:
draw
in interfaceDrawableTexture
- Parameters:
context
- GlimpseContext for drawingtexUnit
- Texture unit to use while drawingmultiTextureList
- Other textures to activate (and their texture units) for multitexturing purposes
-
dispose
public void dispose(com.jogamp.opengl.GLContext context)
Description copied from interface:Texture
Disposes all Java heap and GPU resources associated with this texture.
-
getMaxGLTextureSize
public static int getMaxGLTextureSize(com.jogamp.opengl.GL gl)
-
isResident
@Deprecated public boolean isResident(com.jogamp.opengl.GL2 gl)
Deprecated.Relies onGL2
, so may not work on platforms like OSX that don't support backward-compatible GL profiles likeGLProfile.GL3bc
.
-
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, dimensiondataSizeY
- the number of texture elements in the 2nd, or y, dimension
-
setProjection
public void setProjection(Projection projection)
-
getProjection
public Projection getProjection()
-
-