38package com.jogamp.opengl.util.texture;
40import java.nio.Buffer;
42import com.jogamp.opengl.GLProfile;
44import com.jogamp.common.nio.Buffers;
45import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
60 public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK };
69 private boolean dataIsCompressed;
74 private Buffer[] mipmapData;
134 final int pixelFormat,
137 final boolean dataIsCompressed,
140 final Flusher flusher)
throws IllegalArgumentException {
191 final boolean dataIsCompressed,
194 final Flusher flusher)
throws IllegalArgumentException {
195 if (
mipmap && dataIsCompressed) {
196 throw new IllegalArgumentException(
"Can not generate mipmaps for compressed textures");
199 this.glProfile = glp;
202 this.border = border;
206 this.dataIsCompressed = dataIsCompressed;
209 this.flusher = flusher;
258 final int pixelFormat,
260 final boolean dataIsCompressed,
262 final Buffer[] mipmapData,
263 final Flusher flusher)
throws IllegalArgumentException {
312 final boolean dataIsCompressed,
314 final Buffer[] mipmapData,
315 final Flusher flusher)
throws IllegalArgumentException {
316 this.glProfile = glp;
319 this.border = border;
322 this.dataIsCompressed = dataIsCompressed;
324 this.mipmapData = mipmapData.clone();
325 this.flusher = flusher;
327 for (
int i = 0; i < mipmapData.length; i++) {
385 return dataIsCompressed;
417 public void setBorder(
final int border) { this.border = border; }
491 if (flusher !=
null) {
515 final String optImageType =
null != srcImageType ?
", "+srcImageType :
"";
528 return buffer.capacity() * Buffers.sizeOfBufferElem(
buffer);
Specifies the the OpenGL profile.
final int type
The OpenGL pixel data type
final int format
The OpenGL pixel data format.
static final GLPixelAttributes UNDEF
Undefined instance of GLPixelAttributes, having componentCount:=0, format:=0 and type:= 0.
Image type classification.
Represents the data for an OpenGL texture.
boolean mustFlipVertically
void setHeight(final int height)
Sets the height in pixels of the texture data.
void setBuffer(final Buffer buffer)
Sets the texture data.
void setPixelAttributes(final GLPixelAttributes pixelAttributes)
Sets the intended OpenGL pixel format of the texture data.
void setPixelFormat(final int pixelFormat)
Sets the intended OpenGL pixel format component of GLPixelAttributes of the texture data.
void setColorSpace(final ColorSpace cs)
Set the color space of the pixel data, which defaults to ColorSpace#RGB.
static int estimatedMemorySize(final Buffer buffer)
void setAlignment(final int alignment)
Sets the required byte alignment for the texture data.
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 Flusher flusher)
Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels...
ColorSpace getColorSpace()
Returns the color space of the pixel data.
Buffer[] getMipmapData()
Returns all mipmap levels for the texture data, or null if it is specified as a single image.
int getEstimatedMemorySize()
Returns an estimate of the amount of memory in bytes this TextureData will consume once uploaded to t...
void setRowLength(final int rowLength)
Sets the row length needed for correct GL_UNPACK_ROW_LENGTH specification.
void setMipmap(final boolean mipmap)
Sets whether mipmaps should be generated for the texture data.
TextureData(final GLProfile glp)
Used only by subclasses.
void setPixelType(final int pixelType)
Sets the intended OpenGL pixel type component of GLPixelAttributes of the texture data.
TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final GLPixelAttributes pixelAttributes, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer[] mipmapData, final Flusher flusher)
Constructs a new TextureData object with the specified parameters and data for multiple mipmap levels...
GLPixelAttributes pixelAttributes
int getPixelType()
Returns the intended OpenGL pixel type of the texture data using getPixelAttributes().
GLProfile getGLProfile()
Returns the GLProfile this texture data is intended and created for.
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 Flusher flusher)
Constructs a new TextureData object with the specified parameters and data contained in the given Buf...
GLPixelAttributes getPixelAttributes()
Returns the intended OpenGL GLPixelAttributes of the texture data, i.e.
Buffer getBuffer()
Returns the texture data, or null if it is specified as a set of mipmaps.
TextureData(final GLProfile glp, final int internalFormat, final int width, final int height, final int border, final GLPixelAttributes pixelAttributes, final boolean mipmap, final boolean dataIsCompressed, final boolean mustFlipVertically, final Buffer buffer, final Flusher flusher)
Constructs a new TextureData object with the specified parameters and data contained in the given Buf...
int getAlignment()
Returns the required byte alignment for the texture data.
void setInternalFormat(final int internalFormat)
Sets the intended OpenGL internal format of the texture data.
final ImageType getSourceImageType()
Returns the source ImageType if applicable and known, otherwise null.
void destroy()
Calls flush()
int getInternalFormat()
Returns the intended OpenGL internal format of the texture data.
void setWidth(final int width)
Sets the width in pixels of the texture data.
boolean getMustFlipVertically()
Indicates whether the texture coordinates must be flipped vertically for proper display.
void setBorder(final int border)
Sets the border in pixels of the texture data.
void setMustFlipVertically(final boolean mustFlipVertically)
Sets whether the texture coordinates must be flipped vertically for proper display.
void flush()
Flushes resources associated with this TextureData by calling Flusher.flush().
int getHeight()
Returns the height in pixels of the texture data.
int getPixelFormat()
Returns the intended OpenGL pixel format of the texture data using getPixelAttributes().
int getRowLength()
Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification.
void setHaveGL12(final boolean haveGL12)
Indicates to this TextureData whether OpenGL version 1.2 is available.
boolean isDataCompressed()
Indicates whether the texture data is in compressed form.
int getWidth()
Returns the width in pixels of the texture data.
boolean getMipmap()
Returns whether mipmaps should be generated for the texture data.
void setIsDataCompressed(final boolean compressed)
Sets whether the texture data is in compressed form.
int getBorder()
Returns the border in pixels of the texture data.
void setHaveEXTABGR(final boolean haveEXTABGR)
Indicates to this TextureData whether the GL_EXT_abgr extension is available.
ColorSpace of pixel data.
Defines a callback mechanism to allow the user to explicitly deallocate native resources (memory-mapp...
void flush()
Flushes any native resources associated with this TextureData.