Interface Texture
-
- All Known Subinterfaces:
DrawableTexture
- All Known Implementing Classes:
AbstractTexture
,ByteTextureProjected2D
,ColorTexture1D
,ColorTextureProjected2D
,ExternalTextureProjected2D
,Float16TextureProjected2D
,FloatTexture1D
,FloatTexture2D
,FloatTextureProjected2D
,RGBATextureProjected2D
,RGBTextureProjected2D
,ShortTextureProjected2D
,TextureProjected2D
public interface Texture
Wrapper interface for an OpenGL texture. Provides methods for getting its size, marking it as modified, binding it to a texture unit, and disposing of it properly.- Author:
- osborn
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
dispose(com.jogamp.opengl.GLContext context)
Disposes all Java heap and GPU resources associated with this texture.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.int
getNumDimension()
Returns whether the texture is a 1-dimensional, 2-dimensional, or 3-dimensional texture.boolean
isDirty()
Indicates whethermakeDirty()
has been called.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.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).
-
-
-
Method Detail
-
getHandles
int[] getHandles()
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.
-
makeDirty
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. CallingmakeDirty()
indicates that the contents of this buffer has changed and the new data should be copied to the GPU.
-
isDirty
boolean isDirty()
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.- Returns:
- whether the cached texture data has changed
-
getNumDimension
int getNumDimension()
Returns whether the texture is a 1-dimensional, 2-dimensional, or 3-dimensional texture.- Returns:
- 1, 2, or 3 depending on the dimension of the texture
-
getDimensionSize
int getDimensionSize(int n)
Given a dimension index (0, 1, or 2) returns the number of data elements in the texture along that dimension.- Parameters:
n
- the texture dimension to query- Returns:
- the size of the queried dimension
-
prepare
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). 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
.- Parameters:
gl
- a GL handle for the active GLContexttexUnit
- the texture unit to bind to this texture- Returns:
- whether the preparation succeeded
-
dispose
void dispose(com.jogamp.opengl.GLContext context)
Disposes all Java heap and GPU resources associated with this texture.- Parameters:
context
- the active GLContext
-
-