Top Description Inners Fields Constructors Methods
com.jogamp.opengl.util.texture

public Class TextureData

extends Object
Class Inheritance
Known Direct Subclasses
com.jogamp.opengl.util.texture.awt.AWTTextureData
Imports
java.nio.Buffer, com.jogamp.opengl.GLProfile, com.jogamp.common.nio.Buffers, com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes

Represents the data for an OpenGL texture. This is separated from the notion of a Texture to support things like streaming in of textures in a background thread without requiring an OpenGL context to be current on that thread.
Authors
Chris Campbell, Kenneth Russell, Sven Gothel

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TextureData.ColorSpace

ColorSpace of pixel data.

public static interface
TextureData.Flusher

Defines a callback mechanism to allow the user to explicitly deallocate native resources (memory-mapped files, etc.) associated with a particular TextureData.

Field Summary

Modifier and TypeField and Description
protected int
private int
protected Buffer
private boolean
protected int
private TextureData.Flusher
protected GLProfile
protected boolean
protected boolean
protected int
protected int
protected boolean
private Buffer[]
protected boolean
protected GLPixelBuffer.GLPixelAttributes
protected TextureData.ColorSpace
protected int
pack-priv ImageType
protected int

Constructor Summary

AccessConstructor and Description
public
TextureData(final GLProfile
the OpenGL Profile this texture data should be created for.
glp
,
final int
the OpenGL internal format for the resulting texture; must be specified, may not be 0
internalFormat
,
final int
the width in pixels of the texture
width
,
final int
the height in pixels of the texture
height
,
final int
the number of pixels of border this texture data has (0 or 1)
border
,
final int
the OpenGL pixel format for the resulting texture; must be specified, may not be 0
pixelFormat
,
final int
the OpenGL type of the pixels of the texture
pixelType
,
final boolean
indicates whether mipmaps should be autogenerated (using GLU) for the resulting texture. Currently if mipmap is true then dataIsCompressed may not be true.
mipmap
,
final boolean
indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
dataIsCompressed
,
final boolean
indicates whether the texture coordinates must be flipped vertically in order to properly display the texture
mustFlipVertically
,
final Buffer
the buffer containing the texture data
buffer
,
final TextureData.Flusher
optional flusher to perform cleanup tasks upon call to flush()
flusher
)

Constructs a new TextureData object with the specified parameters and data contained in the given Buffer.

public
TextureData(final GLProfile
the OpenGL Profile this texture data should be created for.
glp
,
final int
the OpenGL internal format for the resulting texture; must be specified, may not be 0
internalFormat
,
final int
the width in pixels of the texture
width
,
final int
the height in pixels of the texture
height
,
final int
the number of pixels of border this texture data has (0 or 1)
border
,
final GLPixelBuffer.GLPixelAttributes
the OpenGL pixel format and type for the resulting texture; must be specified, may not be 0
pixelAttributes
,
final boolean
indicates whether mipmaps should be autogenerated (using GLU) for the resulting texture. Currently if mipmap is true then dataIsCompressed may not be true.
mipmap
,
final boolean
indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
dataIsCompressed
,
final boolean
indicates whether the texture coordinates must be flipped vertically in order to properly display the texture
mustFlipVertically
,
final Buffer
the buffer containing the texture data
buffer
,
final TextureData.Flusher
optional flusher to perform cleanup tasks upon call to flush()
flusher
)

Constructs a new TextureData object with the specified parameters and data contained in the given Buffer.

public
TextureData(final GLProfile
the OpenGL Profile this texture data should be created for.
glp
,
final int
the OpenGL internal format for the resulting texture; must be specified, may not be 0
internalFormat
,
final int
the width in pixels of the topmost mipmap level of the texture
width
,
final int
the height in pixels of the topmost mipmap level of the texture
height
,
final int
the number of pixels of border this texture data has (0 or 1)
border
,
final int
the OpenGL pixel format for the resulting texture; must be specified, may not be 0
pixelFormat
,
final int
the OpenGL type of the pixels of the texture
pixelType
,
final boolean
indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
dataIsCompressed
,
final boolean
indicates whether the texture coordinates must be flipped vertically in order to properly display the texture
mustFlipVertically
,
final Buffer[]
the buffers containing all mipmap levels of the texture's data
mipmapData
,
final TextureData.Flusher
optional flusher to perform cleanup tasks upon call to flush()
flusher
)

Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels contained in the given array of Buffers.

public
TextureData(final GLProfile
the OpenGL Profile this texture data should be created for.
glp
,
final int
the OpenGL internal format for the resulting texture; must be specified, may not be 0
internalFormat
,
final int
the width in pixels of the topmost mipmap level of the texture
width
,
final int
the height in pixels of the topmost mipmap level of the texture
height
,
final int
the number of pixels of border this texture data has (0 or 1)
border
,
final GLPixelBuffer.GLPixelAttributes
the OpenGL pixel format and type for the resulting texture; must be specified, may not be 0
pixelAttributes
,
final boolean
indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
dataIsCompressed
,
final boolean
indicates whether the texture coordinates must be flipped vertically in order to properly display the texture
mustFlipVertically
,
final Buffer[]
the buffers containing all mipmap levels of the texture's data
mipmapData
,
final TextureData.Flusher
optional flusher to perform cleanup tasks upon call to flush()
flusher
)

Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels contained in the given array of Buffers.

protected
TextureData(final GLProfile glp)

Used only by subclasses

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Calls flush()

protected static int
public void
flush()

Flushes resources associated with this TextureData by calling Flusher.flush().

public int
getAlignment()

Returns the required byte alignment for the texture data.

public int
getBorder()

Returns the border in pixels of the texture data.

public Buffer
getBuffer()

Returns the texture data, or null if it is specified as a set of mipmaps.

public TextureData.ColorSpace
getColorSpace()

Returns the color space of the pixel data.

public int
getEstimatedMemorySize()

Returns an estimate of the amount of memory in bytes this TextureData will consume once uploaded to the graphics card.

public GLProfile
getGLProfile()

Returns the GLProfile this texture data is intended and created for.

public int
getHeight()

Returns the height in pixels of the texture data.

public int
getInternalFormat()

Returns the intended OpenGL internal format of the texture data.

public boolean
getMipmap()

Returns whether mipmaps should be generated for the texture data.

public Buffer[]
getMipmapData()

Returns all mipmap levels for the texture data, or null if it is specified as a single image.

public boolean
getMustFlipVertically()

Indicates whether the texture coordinates must be flipped vertically for proper display.

public GLPixelBuffer.GLPixelAttributes
getPixelAttributes()

Returns the intended OpenGL GLPixelAttributes of the texture data, i.e. format and type.

public int
getPixelFormat()

Returns the intended OpenGL pixel format of the texture data using getPixelAttributes().

public int
getPixelType()

Returns the intended OpenGL pixel type of the texture data using getPixelAttributes().

public int
getRowLength()

Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification.

public final ImageType
getSourceImageType()

Returns the source ImageType if applicable and known, otherwise null.

public int
getWidth()

Returns the width in pixels of the texture data.

public boolean
isDataCompressed()

Indicates whether the texture data is in compressed form.

public void
setAlignment(final int alignment)

Sets the required byte alignment for the texture data.

public void
setBorder(final int border)

Sets the border in pixels of the texture data.

public void
setBuffer(final Buffer buffer)

Sets the texture data.

public void
setColorSpace(final TextureData.ColorSpace cs)

Set the color space of the pixel data, which defaults to ColorSpace#RGB.

public void
setHaveEXTABGR(final boolean haveEXTABGR)

Indicates to this TextureData whether the GL_EXT_abgr extension is available.

public void
setHaveGL12(final boolean haveGL12)

Indicates to this TextureData whether OpenGL version 1.2 is available.

public void
setHeight(final int height)

Sets the height in pixels of the texture data.

public void
setInternalFormat(final int internalFormat)

Sets the intended OpenGL internal format of the texture data.

public void
setIsDataCompressed(final boolean compressed)

Sets whether the texture data is in compressed form.

public void
setMipmap(final boolean mipmap)

Sets whether mipmaps should be generated for the texture data.

public void
setMustFlipVertically(final boolean mustFlipVertically)

Sets whether the texture coordinates must be flipped vertically for proper display.

public void
setPixelAttributes(final GLPixelBuffer.GLPixelAttributes pixelAttributes)

Sets the intended OpenGL pixel format of the texture data.

public void
setPixelFormat(final int pixelFormat)

Sets the intended OpenGL pixel format component of GLPixelAttributes of the texture data.

public void
setPixelType(final int pixelType)

Sets the intended OpenGL pixel type component of GLPixelAttributes of the texture data.

public void
setRowLength(final int rowLength)

Sets the row length needed for correct GL_UNPACK_ROW_LENGTH specification.

public void
setWidth(final int width)

Sets the width in pixels of the texture data.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

alignmentback to summary
protected int alignment
borderback to summary
private int border
bufferback to summary
protected Buffer buffer
dataIsCompressedback to summary
private boolean dataIsCompressed
estimatedMemorySizeback to summary
protected int estimatedMemorySize
flusherback to summary
private TextureData.Flusher flusher
glProfileback to summary
protected GLProfile glProfile
haveEXTABGRback to summary
protected boolean haveEXTABGR
haveGL12back to summary
protected boolean haveGL12
heightback to summary
protected int height
internalFormatback to summary
protected int internalFormat
mipmapback to summary
protected boolean mipmap
mipmapDataback to summary
private Buffer[] mipmapData
mustFlipVerticallyback to summary
protected boolean mustFlipVertically
pixelAttributesback to summary
protected GLPixelBuffer.GLPixelAttributes pixelAttributes
pixelCSback to summary
protected TextureData.ColorSpace pixelCS
rowLengthback to summary
protected int rowLength
srcImageTypeback to summary
pack-priv ImageType srcImageType
widthback to summary
protected int width

Constructor Detail

TextureDataback to summary
public TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final int pixelFormat, final int pixelType, final boolean mipmap, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer buffer, final TextureData.Flusher flusher) throws IllegalArgumentException

Constructs a new TextureData object with the specified parameters and data contained in the given Buffer. The optional Flusher can be used to clean up native resources associated with this TextureData when processing is complete; for example, closing of memory-mapped files that might otherwise require a garbage collection to reclaim and close.

Parameters
glp:GLProfile

the OpenGL Profile this texture data should be created for.

internalFormat:int

the OpenGL internal format for the resulting texture; must be specified, may not be 0

width:int

the width in pixels of the texture

height:int

the height in pixels of the texture

border:int

the number of pixels of border this texture data has (0 or 1)

pixelFormat:int

the OpenGL pixel format for the resulting texture; must be specified, may not be 0

pixelType:int

the OpenGL type of the pixels of the texture

mipmap:boolean

indicates whether mipmaps should be autogenerated (using GLU) for the resulting texture. Currently if mipmap is true then dataIsCompressed may not be true.

dataIsCompressed:boolean

indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)

mustFlipVertically:boolean

indicates whether the texture coordinates must be flipped vertically in order to properly display the texture

buffer:Buffer

the buffer containing the texture data

flusher:TextureData.Flusher

optional flusher to perform cleanup tasks upon call to flush()

Exceptions
IllegalArgumentException:
if any parameters of the texture data were invalid, such as requesting mipmap generation for a compressed texture
TextureDataback to summary
public TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean mipmap, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer buffer, final TextureData.Flusher flusher) throws IllegalArgumentException

Constructs a new TextureData object with the specified parameters and data contained in the given Buffer. The optional Flusher can be used to clean up native resources associated with this TextureData when processing is complete; for example, closing of memory-mapped files that might otherwise require a garbage collection to reclaim and close.

Parameters
glp:GLProfile

the OpenGL Profile this texture data should be created for.

internalFormat:int

the OpenGL internal format for the resulting texture; must be specified, may not be 0

width:int

the width in pixels of the texture

height:int

the height in pixels of the texture

border:int

the number of pixels of border this texture data has (0 or 1)

pixelAttributes:GLPixelBuffer.GLPixelAttributes

the OpenGL pixel format and type for the resulting texture; must be specified, may not be 0

mipmap:boolean

indicates whether mipmaps should be autogenerated (using GLU) for the resulting texture. Currently if mipmap is true then dataIsCompressed may not be true.

dataIsCompressed:boolean

indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)

mustFlipVertically:boolean

indicates whether the texture coordinates must be flipped vertically in order to properly display the texture

buffer:Buffer

the buffer containing the texture data

flusher:TextureData.Flusher

optional flusher to perform cleanup tasks upon call to flush()

Exceptions
IllegalArgumentException:
if any parameters of the texture data were invalid, such as requesting mipmap generation for a compressed texture
TextureDataback to summary
public TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final int pixelFormat, final int pixelType, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer[] mipmapData, final TextureData.Flusher flusher) throws IllegalArgumentException

Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels contained in the given array of Buffers. The optional Flusher can be used to clean up native resources associated with this TextureData when processing is complete; for example, closing of memory-mapped files that might otherwise require a garbage collection to reclaim and close.

Parameters
glp:GLProfile

the OpenGL Profile this texture data should be created for.

internalFormat:int

the OpenGL internal format for the resulting texture; must be specified, may not be 0

width:int

the width in pixels of the topmost mipmap level of the texture

height:int

the height in pixels of the topmost mipmap level of the texture

border:int

the number of pixels of border this texture data has (0 or 1)

pixelFormat:int

the OpenGL pixel format for the resulting texture; must be specified, may not be 0

pixelType:int

the OpenGL type of the pixels of the texture

dataIsCompressed:boolean

indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)

mustFlipVertically:boolean

indicates whether the texture coordinates must be flipped vertically in order to properly display the texture

mipmapData:Buffer[]

the buffers containing all mipmap levels of the texture's data

flusher:TextureData.Flusher

optional flusher to perform cleanup tasks upon call to flush()

Exceptions
IllegalArgumentException:
if any parameters of the texture data were invalid, such as requesting mipmap generation for a compressed texture
TextureDataback to summary
public TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final GLPixelBuffer.GLPixelAttributes pixelAttributes, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer[] mipmapData, final TextureData.Flusher flusher) throws IllegalArgumentException

Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels contained in the given array of Buffers. The optional Flusher can be used to clean up native resources associated with this TextureData when processing is complete; for example, closing of memory-mapped files that might otherwise require a garbage collection to reclaim and close.

Parameters
glp:GLProfile

the OpenGL Profile this texture data should be created for.

internalFormat:int

the OpenGL internal format for the resulting texture; must be specified, may not be 0

width:int

the width in pixels of the topmost mipmap level of the texture

height:int

the height in pixels of the topmost mipmap level of the texture

border:int

the number of pixels of border this texture data has (0 or 1)

pixelAttributes:GLPixelBuffer.GLPixelAttributes

the OpenGL pixel format and type for the resulting texture; must be specified, may not be 0

dataIsCompressed:boolean

indicates whether the texture data is in compressed form (e.g. GL_COMPRESSED_RGB_S3TC_DXT1_EXT)

mustFlipVertically:boolean

indicates whether the texture coordinates must be flipped vertically in order to properly display the texture

mipmapData:Buffer[]

the buffers containing all mipmap levels of the texture's data

flusher:TextureData.Flusher

optional flusher to perform cleanup tasks upon call to flush()

Exceptions
IllegalArgumentException:
if any parameters of the texture data were invalid, such as requesting mipmap generation for a compressed texture
TextureDataback to summary
protected TextureData(final GLProfile glp)

Used only by subclasses

Method Detail

destroyback to summary
public void destroy()

Calls flush()

See Also
flush()
estimatedMemorySizeback to summary
protected static int estimatedMemorySize(final Buffer buffer)
flushback to summary
public void flush()

Flushes resources associated with this TextureData by calling Flusher.flush().

getAlignmentback to summary
public int getAlignment()

Returns the required byte alignment for the texture data.

getBorderback to summary
public int getBorder()

Returns the border in pixels of the texture data.

getBufferback to summary
public Buffer getBuffer()

Returns the texture data, or null if it is specified as a set of mipmaps.

getColorSpaceback to summary
public TextureData.ColorSpace getColorSpace()

Returns the color space of the pixel data.

See Also
setColorSpace(ColorSpace)
getEstimatedMemorySizeback to summary
public int getEstimatedMemorySize()

Returns an estimate of the amount of memory in bytes this TextureData will consume once uploaded to the graphics card. It should only be treated as an estimate; most applications should not need to query this but instead let the OpenGL implementation page textures in and out as necessary.

getGLProfileback to summary
public GLProfile getGLProfile()

Returns the GLProfile this texture data is intended and created for.

getHeightback to summary
public int getHeight()

Returns the height in pixels of the texture data.

getInternalFormatback to summary
public int getInternalFormat()

Returns the intended OpenGL internal format of the texture data.

getMipmapback to summary
public boolean getMipmap()

Returns whether mipmaps should be generated for the texture data.

getMipmapDataback to summary
public Buffer[] getMipmapData()

Returns all mipmap levels for the texture data, or null if it is specified as a single image.

getMustFlipVerticallyback to summary
public boolean getMustFlipVertically()

Indicates whether the texture coordinates must be flipped vertically for proper display.

getPixelAttributesback to summary
public GLPixelBuffer.GLPixelAttributes getPixelAttributes()

Returns the intended OpenGL GLPixelAttributes of the texture data, i.e. format and type.

getPixelFormatback to summary
public int getPixelFormat()

Returns the intended OpenGL pixel format of the texture data using getPixelAttributes().

getPixelTypeback to summary
public int getPixelType()

Returns the intended OpenGL pixel type of the texture data using getPixelAttributes().

getRowLengthback to summary
public int getRowLength()

Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures.

getSourceImageTypeback to summary
public final ImageType getSourceImageType()

Returns the source ImageType if applicable and known, otherwise null.

Since
2.3.2
getWidthback to summary
public int getWidth()

Returns the width in pixels of the texture data.

isDataCompressedback to summary
public boolean isDataCompressed()

Indicates whether the texture data is in compressed form.

setAlignmentback to summary
public void setAlignment(final int alignment)

Sets the required byte alignment for the texture data.

setBorderback to summary
public void setBorder(final int border)

Sets the border in pixels of the texture data.

setBufferback to summary
public void setBuffer(final Buffer buffer)

Sets the texture data.

setColorSpaceback to summary
public void setColorSpace(final TextureData.ColorSpace cs)

Set the color space of the pixel data, which defaults to ColorSpace#RGB.

See Also
getColorSpace()
setHaveEXTABGRback to summary
public void setHaveEXTABGR(final boolean haveEXTABGR)

Indicates to this TextureData whether the GL_EXT_abgr extension is available. Used for optimization along some code paths to avoid data copies.

setHaveGL12back to summary
public void setHaveGL12(final boolean haveGL12)

Indicates to this TextureData whether OpenGL version 1.2 is available. If not, falls back to relatively inefficient code paths for several input data types (several kinds of packed pixel formats, in particular).

setHeightback to summary
public void setHeight(final int height)

Sets the height in pixels of the texture data.

setInternalFormatback to summary
public void setInternalFormat(final int internalFormat)

Sets the intended OpenGL internal format of the texture data.

setIsDataCompressedback to summary
public void setIsDataCompressed(final boolean compressed)

Sets whether the texture data is in compressed form.

setMipmapback to summary
public void setMipmap(final boolean mipmap)

Sets whether mipmaps should be generated for the texture data.

setMustFlipVerticallyback to summary
public void setMustFlipVertically(final boolean mustFlipVertically)

Sets whether the texture coordinates must be flipped vertically for proper display.

setPixelAttributesback to summary
public void setPixelAttributes(final GLPixelBuffer.GLPixelAttributes pixelAttributes)

Sets the intended OpenGL pixel format of the texture data.

setPixelFormatback to summary
public void setPixelFormat(final int pixelFormat)

Sets the intended OpenGL pixel format component of GLPixelAttributes of the texture data.

Use setPixelAttributes(GLPixelAttributes), if setting format and type.

setPixelTypeback to summary
public void setPixelType(final int pixelType)

Sets the intended OpenGL pixel type component of GLPixelAttributes of the texture data.

Use setPixelAttributes(GLPixelAttributes), if setting format and type.

setRowLengthback to summary
public void setRowLength(final int rowLength)

Sets the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures.

setWidthback to summary
public void setWidth(final int width)

Sets the width in pixels of the texture data.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.opengl.util.texture back to summary

public final Enum TextureData.ColorSpace

extends Enum<TextureData.ColorSpace>
Class Inheritance

ColorSpace of pixel data.

Field Summary

Modifier and TypeField and Description
public static final TextureData.ColorSpace
public static final TextureData.ColorSpace
public static final TextureData.ColorSpace
public static final TextureData.ColorSpace

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TextureData.ColorSpace
public static TextureData.ColorSpace[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CMYKback to summary
public static final TextureData.ColorSpace CMYK
RGBback to summary
public static final TextureData.ColorSpace RGB
YCbCrback to summary
public static final TextureData.ColorSpace YCbCr
YCCKback to summary
public static final TextureData.ColorSpace YCCK

Constructor Detail

ColorSpaceback to summary
private ColorSpace()

Method Detail

valueOfback to summary
public static TextureData.ColorSpace valueOf(String name)
valuesback to summary
public static TextureData.ColorSpace[] values()
com.jogamp.opengl.util.texture back to summary

public Interface TextureData.Flusher


Defines a callback mechanism to allow the user to explicitly deallocate native resources (memory-mapped files, etc.) associated with a particular TextureData.

Method Summary

Modifier and TypeMethod and Description
public void
flush()

Flushes any native resources associated with this TextureData.

Method Detail

flushback to summary
public void flush()

Flushes any native resources associated with this TextureData.