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

public Class Texture

extends Object
Class Inheritance
Imports
java.nio.*, com.jogamp.opengl.*, .GLExtensions, com.jogamp.opengl.glu.*, com.jogamp.nativewindow.NativeWindowFactory, jogamp.opengl.*, com.jogamp.opengl.util.texture.spi.*

Represents an OpenGL texture object. Contains convenience routines for enabling/disabling OpenGL texture state, binding this texture, and computing texture coordinates for both the entire image as well as a sub-image.
Order of Texture Commands

Due to many confusions w/ texture usage, following list described the order and semantics of texture unit selection, binding and enabling.

Non-power-of-two restrictions
When creating an OpenGL texture object, the Texture class will attempt to use non-power-of-two textures (NPOT) if available, see GL#isNPOTTextureAvailable(). Further more, GL_ARB_texture_rectangle (RECT) will be attempted on OSX w/ ATI drivers. If NPOT is not available or RECT not chosen, the Texture class will simply upload a non-pow2-sized image into a standard pow2-sized texture (without any special scaling). Since the choice of extension (or whether one is used at all) depends on the user's machine configuration, developers are recommended to use getImageTexCoords and getSubImageTexCoords, as those methods will calculate the appropriate texture coordinates for the situation.

One caveat in this approach is that certain texture wrap modes (e.g. GL_REPEAT) are not legal when the GL_ARB_texture_rectangle extension is in use. Another issue to be aware of is that in the default pow2 scenario, if the original image does not have pow2 dimensions, then wrapping may not work as one might expect since the image does not extend to the edges of the pow2 texture. If texture wrapping is important, it is recommended to use only pow2-sized images with the Texture class.

Performance Tips
For best performance, try to avoid calling enable / bind / disable any more than necessary. For example, applications using many Texture objects in the same scene may want to reduce the number of calls to both enable and disable. To do this it is necessary to call getTarget to make sure the OpenGL texture target is the same for all of the Texture objects in use; non-power-of-two textures using the GL_ARB_texture_rectangle extension use a different target than power-of-two textures using the GL_TEXTURE_2D target. Note that when switching between textures it is necessary to call bind, but when drawing many triangles all using the same texture, for best performance only one call to bind should be made. User may also utilize multiple texture units, see order of texture commands above.

Alpha premultiplication and blending

Disclaimer: Consider performing alpha premultiplication in shader code, if really desired! Otherwise use RGBA.

The Texture class does not convert RGBA image data into premultiplied data when storing it into an OpenGL texture.

The mathematically correct way to perform blending in OpenGL with the SrcOver "source over destination" mode, or any other Porter-Duff rule, is to use premultiplied color components, which means the R/G/ B color components must have been multiplied by the alpha value. If using premultiplied color components it is important to use the correct blending function; for example, the SrcOver rule is expressed as:

    gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
Also, when using a texture function like GL_MODULATE where the current color plays a role, it is important to remember to make sure that the color is specified in a premultiplied form, for example:
    float a = ...;
    float r = r * a;
    float g = g * a;
    float b = b * a;
    gl.glColor4f(r, g, b, a);
For reference, here is a list of the Porter-Duff compositing rules and the associated OpenGL blend functions (source and destination factors) to use in the face of premultiplied alpha:
Rule Source Dest
Clear GL_ZERO GL_ZERO
Src GL_ONE GL_ZERO
SrcOver GL_ONE GL_ONE_MINUS_SRC_ALPHA
DstOver GL_ONE_MINUS_DST_ALPHA GL_ONE
SrcIn GL_DST_ALPHA GL_ZERO
DstIn GL_ZERO GL_SRC_ALPHA
SrcOut GL_ONE_MINUS_DST_ALPHA GL_ZERO
DstOut GL_ZERO GL_ONE_MINUS_SRC_ALPHA
Dst GL_ZERO GL_ONE
SrcAtop GL_DST_ALPHA GL_ONE_MINUS_SRC_ALPHA
DstAtop GL_ONE_MINUS_DST_ALPHA GL_SRC_ALPHA
AlphaXor GL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_SRC_ALPHA
Author
Chris Campbell, Kenneth Russell, et.al.

Field Summary

Modifier and TypeField and Description
private float
aspectRatio

The original aspect ratio of the image, before any rescaling that might have occurred due to using the GLU mipmap routines.

private TextureCoords
coords

The texture coordinates corresponding to the entire image.

private static final boolean
private static final boolean
private static final boolean
private int
estimatedMemorySize

An estimate of the amount of texture memory this texture consumes.

private int
imageTarget

The image GL target type for this texture, or its sub-components if cubemap.

private int
imgHeight

The height of the image.

private int
imgWidth

The width of the image.

private boolean
mustFlipVertically

Indicates whether the TextureData requires a vertical flip of the texture coords.

private int
target

The GL target type for this texture.

private int
texHeight

The height of the texture.

private int
texID

The GL texture ID.

private int
texWidth

The width of the texture.

private boolean
usingAutoMipmapGeneration

Indicates whether we're using automatic mipmap generation support (GL_GENERATE_MIPMAP).

private static final boolean

Constructor Summary

AccessConstructor and Description
public
Texture(final GL gl, final TextureData data)

public
Texture(final int
the OpenGL texture target, eg GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_RECTANGLE
target
)

Constructor for use when creating e.g. cube maps, where there is no initial texture data

public
Texture(final int
the OpenGL texture object to wrap
textureID
,
final int
the OpenGL texture target, eg GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_RECTANGLE
target
,
final int
the width of the texture in pixels
texWidth
,
final int
the height of the texture in pixels
texHeight
,
final int
the width of the image within the texture in pixels (if the content is a sub-rectangle in the upper left corner); otherwise, pass in texWidth
imgWidth
,
final int
the height of the image within the texture in pixels (if the content is a sub-rectangle in the upper left corner); otherwise, pass in texHeight
imgHeight
,
final boolean
indicates whether the texture coordinates must be flipped vertically in order to properly display the texture
mustFlipVertically
)

Constructor to wrap an OpenGL texture ID from an external library and allows some of the base methods from the Texture class, such as binding and querying of texture coordinates, to be used with it.

Method Summary

Modifier and TypeMethod and Description
public void
bind(final GL
the current GL context
gl
)

Binds this texture to the given GL context.

private void
public void
destroy(final GL gl)

Destroys the native resources used by this texture object.

public void
disable(final GL
the current GL object
gl
)

Disables this texture's target (e.g., GL_TEXTURE_2D) in the given GL state.

public void
enable(final GL
the current GL object
gl
)

Enables this texture's target (e.g., GL_TEXTURE_2D) in the given GL context's state.

public float
getAspectRatio()

Returns the original aspect ratio of the image, defined as (image width) / (image height), before any scaling that might have occurred as a result of using the GLU mipmap routines.

public int
getEstimatedMemorySize()

Returns an estimate of the amount of texture memory in bytes this Texture consumes.

public int

Returns:

the height of the texture
getHeight
()

Returns the height of the allocated OpenGL texture in pixels.

public int

Returns:

the height of the image
getImageHeight
()

Returns the height of the image contained within this texture.

public int
getImageTarget()

Returns the image OpenGL "target" of this texture, or its sub-components if cubemap.

public TextureCoords

Returns:

the texture coordinates corresponding to the entire image
getImageTexCoords
()

Returns the set of texture coordinates corresponding to the entire image.

public int

Returns:

the width of the image
getImageWidth
()

Returns the width of the image contained within this texture.

public boolean
getMustFlipVertically()

Indicates whether this texture's texture coordinates must be flipped vertically in order to properly display the texture.

public TextureCoords

Returns:

the texture coordinates corresponding to the specified sub-image
getSubImageTexCoords
(final int x1, final int y1, final int x2, final int y2)

Returns the set of texture coordinates corresponding to the specified sub-image.

public int
getTarget()

Returns the OpenGL "target" of this texture.

public int
getTextureObject(final GL
required to be valid and current in case the texture object has not been generated yet, otherwise it may be null.
gl
)

Returns the underlying OpenGL texture object for this texture and generates it if not done yet.

public int
getTextureObject()

Returns the underlying OpenGL texture object for this texture, maybe 0 if not yet generated.

public int

Returns:

the width of the texture
getWidth
()

Returns the width of the allocated OpenGL texture in pixels.

private static boolean
haveNPOT(final GL gl)

private static boolean
haveTexRect(final GL gl)

private static boolean

Returns:

true if the given value is a power of two, false otherwise
isPowerOfTwo
(final int val)

Returns true if the given value is a power of two.

public boolean
isUsingAutoMipmapGeneration()

Indicates whether this Texture is using automatic mipmap generation (via the OpenGL texture parameter GL_GENERATE_MIPMAP).

private static int

Returns:

the next power of two
nextPowerOfTwo
(final int
the value
val
)

Returns the nearest power of two that is larger than the given value.

private static boolean
preferTexRect(final GL gl)

public void
setMustFlipVertically(final boolean v)

Change whether the TextureData requires a vertical flip of the texture coords.

public void
setTexParameterf(final GL gl, final int parameterName, final float value)

Sets the OpenGL floating-point texture parameter for the texture's target.

public void
setTexParameterfv(final GL gl, final int parameterName, final FloatBuffer params)

Sets the OpenGL multi-floating-point texture parameter for the texture's target.

public void
setTexParameterfv(final GL gl, final int parameterName, final float[] params, final int params_offset)

Sets the OpenGL multi-floating-point texture parameter for the texture's target.

public void
setTexParameteri(final GL gl, final int parameterName, final int value)

Sets the OpenGL integer texture parameter for the texture's target.

public void
setTexParameteriv(final GL gl, final int parameterName, final IntBuffer params)

Sets the OpenGL multi-integer texture parameter for the texture's target.

public void
setTexParameteriv(final GL gl, final int parameterName, final int[] params, final int params_offset)

Sets the OpenGL multi-integer texture parameter for the texture's target.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
updateImage(final GL gl, final TextureData data)

Updates the entire content area incl.

public void
updateImage(final GL gl, final TextureData data, final int targetOverride)

Updates the content area incl.

public void
updateSubImage(final GL gl, final TextureData
the image data to be uploaded to this texture
data
,
final int
the mipmap level of the texture to set. If this is non-zero and the TextureData contains mipmap data, the appropriate mipmap level will be selected.
mipmapLevel
,
final int
the x offset (in pixels) relative to the lower-left corner of this texture
x
,
final int
the y offset (in pixels) relative to the lower-left corner of this texture
y
)

Updates a subregion of the content area of this texture using the given data.

public void
updateSubImage(final GL gl, final TextureData
the image data to be uploaded to this texture
data
,
final int
the mipmap level of the texture to set. If this is non-zero and the TextureData contains mipmap data, the appropriate mipmap level will be selected.
mipmapLevel
,
final int
the x offset (in pixels) relative to the lower-left corner of this texture where the update will be applied
dstx
,
final int
the y offset (in pixels) relative to the lower-left corner of this texture where the update will be applied
dsty
,
final int
the x offset (in pixels) relative to the lower-left corner of the supplied TextureData from which to fetch the update rectangle
srcx
,
final int
the y offset (in pixels) relative to the lower-left corner of the supplied TextureData from which to fetch the update rectangle
srcy
,
final int
the width (in pixels) of the rectangle to be updated
width
,
final int
the height (in pixels) of the rectangle to be updated
height
)

Updates a subregion of the content area of this texture using the specified sub-region of the given data.

private void
updateSubImageImpl(final GL gl, final TextureData data, final int newTarget, final int mipmapLevel, int dstx, int dsty, int srcx, int srcy, int width, int height)

private void
private boolean
validateTexID(final GL gl, final boolean throwException)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aspectRatioback to summary
private float aspectRatio

The original aspect ratio of the image, before any rescaling that might have occurred due to using the GLU mipmap routines.

coordsback to summary
private TextureCoords coords

The texture coordinates corresponding to the entire image.

DEBUGback to summary
private static final boolean DEBUG
disableNPOTback to summary
private static final boolean disableNPOT
disableTexRectback to summary
private static final boolean disableTexRect
estimatedMemorySizeback to summary
private int estimatedMemorySize

An estimate of the amount of texture memory this texture consumes.

imageTargetback to summary
private int imageTarget

The image GL target type for this texture, or its sub-components if cubemap.

imgHeightback to summary
private int imgHeight

The height of the image.

imgWidthback to summary
private int imgWidth

The width of the image.

mustFlipVerticallyback to summary
private boolean mustFlipVertically

Indicates whether the TextureData requires a vertical flip of the texture coords.

targetback to summary
private int target

The GL target type for this texture.

texHeightback to summary
private int texHeight

The height of the texture.

texIDback to summary
private int texID

The GL texture ID.

texWidthback to summary
private int texWidth

The width of the texture.

usingAutoMipmapGenerationback to summary
private boolean usingAutoMipmapGeneration

Indicates whether we're using automatic mipmap generation support (GL_GENERATE_MIPMAP).

VERBOSEback to summary
private static final boolean VERBOSE

Constructor Detail

Textureback to summary
public Texture(final GL gl, final TextureData data) throws GLException
Textureback to summary
public Texture(final int target)

Constructor for use when creating e.g. cube maps, where there is no initial texture data

Parameters
target:int

the OpenGL texture target, eg GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_RECTANGLE

Textureback to summary
public Texture(final int textureID, final int target, final int texWidth, final int texHeight, final int imgWidth, final int imgHeight, final boolean mustFlipVertically)

Constructor to wrap an OpenGL texture ID from an external library and allows some of the base methods from the Texture class, such as binding and querying of texture coordinates, to be used with it. Attempts to update such textures' contents will yield undefined results.

Parameters
textureID:int

the OpenGL texture object to wrap

target:int

the OpenGL texture target, eg GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_RECTANGLE

texWidth:int

the width of the texture in pixels

texHeight:int

the height of the texture in pixels

imgWidth:int

the width of the image within the texture in pixels (if the content is a sub-rectangle in the upper left corner); otherwise, pass in texWidth

imgHeight:int

the height of the image within the texture in pixels (if the content is a sub-rectangle in the upper left corner); otherwise, pass in texHeight

mustFlipVertically:boolean

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

Method Detail

bindback to summary
public void bind(final GL gl) throws GLException

Binds this texture to the given GL context. This method is a shorthand equivalent of the following OpenGL code:

    gl.glBindTexture(texture.getTarget(), texture.getTextureObject());
    
See the performance tips above for hints on how to maximize performance when using many Texture objects.
Parameters
gl:GL

the current GL context

Exceptions
GLException:
if no OpenGL context was current or if any OpenGL-related errors occurred
checkCompressedTextureExtensionsback to summary
private void checkCompressedTextureExtensions(final GL gl, final TextureData data)
destroyback to summary
public void destroy(final GL gl) throws GLException

Destroys the native resources used by this texture object.

Exceptions
GLException:
if any OpenGL-related errors occurred
disableback to summary
public void disable(final GL gl) throws GLException

Disables this texture's target (e.g., GL_TEXTURE_2D) in the given GL state. This method is a shorthand equivalent of the following OpenGL code:

  gl.glDisable(texture.getTarget());

Call is ignored if the GL object's context is using a core profile, see GL#isGLcore(), or if getTarget() is GLES2#GL_TEXTURE_EXTERNAL_OES.

See the performance tips above for hints on how to maximize performance when using many Texture objects.

Parameters
gl:GL

the current GL object

Exceptions
GLException:
if no OpenGL context was current or if any OpenGL-related errors occurred
enableback to summary
public void enable(final GL gl) throws GLException

Enables this texture's target (e.g., GL_TEXTURE_2D) in the given GL context's state. This method is a shorthand equivalent of the following OpenGL code:

  gl.glEnable(texture.getTarget());

Call is ignored if the GL object's context is using a core profile, see GL#isGLcore(), or if getTarget() is GLES2#GL_TEXTURE_EXTERNAL_OES.

See the performance tips above for hints on how to maximize performance when using many Texture objects.

Parameters
gl:GL

the current GL object

Exceptions
GLException:
if no OpenGL context was current or if any OpenGL-related errors occurred
getAspectRatioback to summary
public float getAspectRatio()

Returns the original aspect ratio of the image, defined as (image width) / (image height), before any scaling that might have occurred as a result of using the GLU mipmap routines.

getEstimatedMemorySizeback to summary
public int getEstimatedMemorySize()

Returns an estimate of the amount of texture memory in bytes this Texture consumes. 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.

getHeightback to summary
public int getHeight()

Returns the height of the allocated OpenGL texture in pixels. Note that the texture height will be greater than or equal to the height of the image contained within.

Returns:int

the height of the texture

getImageHeightback to summary
public int getImageHeight()

Returns the height of the image contained within this texture. Note that for non-power-of-two textures in particular this may not be equal to the result of getHeight. It is recommended that applications call getImageTexCoords and getSubImageTexCoords rather than using this API directly.

Returns:int

the height of the image

getImageTargetback to summary
public int getImageTarget()

Returns the image OpenGL "target" of this texture, or its sub-components if cubemap.

See Also
com.jogamp.opengl.GL#GL_TEXTURE_2D, com.jogamp.opengl.GL2#GL_TEXTURE_RECTANGLE_ARB
getImageTexCoordsback to summary
public TextureCoords getImageTexCoords()

Returns the set of texture coordinates corresponding to the entire image. If the TextureData indicated that the texture coordinates must be flipped vertically, the returned TextureCoords will take that into account.

Returns:TextureCoords

the texture coordinates corresponding to the entire image

getImageWidthback to summary
public int getImageWidth()

Returns the width of the image contained within this texture. Note that for non-power-of-two textures in particular this may not be equal to the result of getWidth. It is recommended that applications call getImageTexCoords and getSubImageTexCoords rather than using this API directly.

Returns:int

the width of the image

getMustFlipVerticallyback to summary
public boolean getMustFlipVertically()

Indicates whether this texture's texture coordinates must be flipped vertically in order to properly display the texture. This is handled automatically by getImageTexCoords and getSubImageTexCoords, but applications may generate or otherwise produce texture coordinates which must be corrected.

getSubImageTexCoordsback to summary
public TextureCoords getSubImageTexCoords(final int x1, final int y1, final int x2, final int y2)

Returns the set of texture coordinates corresponding to the specified sub-image. The (x1, y1) and (x2, y2) points are specified in terms of pixels starting from the lower-left of the image. (x1, y1) should specify the lower-left corner of the sub-image and (x2, y2) the upper-right corner of the sub-image. If the TextureData indicated that the texture coordinates must be flipped vertically, the returned TextureCoords will take that into account; this should not be handled by the end user in the specification of the y1 and y2 coordinates.

Returns:TextureCoords

the texture coordinates corresponding to the specified sub-image

getTargetback to summary
public int getTarget()

Returns the OpenGL "target" of this texture.

See Also
com.jogamp.opengl.GL#GL_TEXTURE_2D, com.jogamp.opengl.GL2#GL_TEXTURE_RECTANGLE_ARB
getTextureObjectback to summary
public int getTextureObject(final GL gl)

Returns the underlying OpenGL texture object for this texture and generates it if not done yet.

Most applications will not need to access this, since it is handled automatically by the bind(GL) and destroy(GL) APIs.

Parameters
gl:GL

required to be valid and current in case the texture object has not been generated yet, otherwise it may be null.

See Also
getTextureObject()
getTextureObjectback to summary
public int getTextureObject()

Returns the underlying OpenGL texture object for this texture, maybe 0 if not yet generated.

Most applications will not need to access this, since it is handled automatically by the bind(GL) and destroy(GL) APIs.

See Also
getTextureObject(GL)
getWidthback to summary
public int getWidth()

Returns the width of the allocated OpenGL texture in pixels. Note that the texture width will be greater than or equal to the width of the image contained within.

Returns:int

the width of the texture

haveNPOTback to summary
private static boolean haveNPOT(final GL gl)
haveTexRectback to summary
private static boolean haveTexRect(final GL gl)
isPowerOfTwoback to summary
private static boolean isPowerOfTwo(final int val)

Returns true if the given value is a power of two.

Returns:boolean

true if the given value is a power of two, false otherwise

isUsingAutoMipmapGenerationback to summary
public boolean isUsingAutoMipmapGeneration()

Indicates whether this Texture is using automatic mipmap generation (via the OpenGL texture parameter GL_GENERATE_MIPMAP). This will automatically be used when mipmapping is requested via the TextureData and either OpenGL 1.4 or the GL_SGIS_generate_mipmap extension is available. If so, updates to the base image (mipmap level 0) will automatically propagate down to the lower mipmap levels. Manual updates of the mipmap data at these lower levels will be ignored.

nextPowerOfTwoback to summary
private static int nextPowerOfTwo(final int val)

Returns the nearest power of two that is larger than the given value. If the given value is already a power of two, this method will simply return that value.

Parameters
val:int

the value

Returns:int

the next power of two

preferTexRectback to summary
private static boolean preferTexRect(final GL gl)
setMustFlipVerticallyback to summary
public void setMustFlipVertically(final boolean v)

Change whether the TextureData requires a vertical flip of the texture coords.

No-op if no change, otherwise generates new TextureCoords.

setTexParameterfback to summary
public void setTexParameterf(final GL gl, final int parameterName, final float value)

Sets the OpenGL floating-point texture parameter for the texture's target. This gives control over parameters such as GL_TEXTURE_MAX_ANISOTROPY_EXT. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if no OpenGL context was current or if any OpenGL-related errors occurred
setTexParameterfvback to summary
public void setTexParameterfv(final GL gl, final int parameterName, final FloatBuffer params)

Sets the OpenGL multi-floating-point texture parameter for the texture's target. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if any OpenGL-related errors occurred
setTexParameterfvback to summary
public void setTexParameterfv(final GL gl, final int parameterName, final float[] params, final int params_offset)

Sets the OpenGL multi-floating-point texture parameter for the texture's target. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if any OpenGL-related errors occurred
setTexParameteriback to summary
public void setTexParameteri(final GL gl, final int parameterName, final int value)

Sets the OpenGL integer texture parameter for the texture's target. This gives control over parameters such as GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T, which by default are set to GL_CLAMP_TO_EDGE if OpenGL 1.2 is supported on the current platform and GL_CLAMP if not. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if any OpenGL-related errors occurred
setTexParameterivback to summary
public void setTexParameteriv(final GL gl, final int parameterName, final IntBuffer params)

Sets the OpenGL multi-integer texture parameter for the texture's target. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if any OpenGL-related errors occurred
setTexParameterivback to summary
public void setTexParameteriv(final GL gl, final int parameterName, final int[] params, final int params_offset)

Sets the OpenGL multi-integer texture parameter for the texture's target. Causes this texture to be bound to the current texture state.

Exceptions
GLException:
if any OpenGL-related errors occurred
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
updateImageback to summary
public void updateImage(final GL gl, final TextureData data) throws GLException

Updates the entire content area incl. TextureCoords of this texture using the data in the given image.

Exceptions
GLException:
if any OpenGL-related errors occurred
updateImageback to summary
public void updateImage(final GL gl, final TextureData data, final int targetOverride) throws GLException

Updates the content area incl. TextureCoords of the specified target of this texture using the data in the given image. In general this is intended for construction of cube maps.

Exceptions
GLException:
if any OpenGL-related errors occurred
updateSubImageback to summary
public void updateSubImage(final GL gl, final TextureData data, final int mipmapLevel, final int x, final int y) throws GLException

Updates a subregion of the content area of this texture using the given data. If automatic mipmap generation is in use (see isUsingAutoMipmapGeneration), updates to the base (level 0) mipmap will cause the lower-level mipmaps to be regenerated, and updates to other mipmap levels will be ignored. Otherwise, if automatic mipmap generation is not in use, only updates the specified mipmap level and does not re-generate mipmaps if they were originally produced or loaded.

Parameters
data:TextureData

the image data to be uploaded to this texture

mipmapLevel:int

the mipmap level of the texture to set. If this is non-zero and the TextureData contains mipmap data, the appropriate mipmap level will be selected.

x:int

the x offset (in pixels) relative to the lower-left corner of this texture

y:int

the y offset (in pixels) relative to the lower-left corner of this texture

Exceptions
GLException:
if any OpenGL-related errors occurred
updateSubImageback to summary
public void updateSubImage(final GL gl, final TextureData data, final int mipmapLevel, final int dstx, final int dsty, final int srcx, final int srcy, final int width, final int height) throws GLException

Updates a subregion of the content area of this texture using the specified sub-region of the given data. If automatic mipmap generation is in use (see isUsingAutoMipmapGeneration), updates to the base (level 0) mipmap will cause the lower-level mipmaps to be regenerated, and updates to other mipmap levels will be ignored. Otherwise, if automatic mipmap generation is not in use, only updates the specified mipmap level and does not re-generate mipmaps if they were originally produced or loaded. This method is only supported for uncompressed TextureData sources.

Parameters
data:TextureData

the image data to be uploaded to this texture

mipmapLevel:int

the mipmap level of the texture to set. If this is non-zero and the TextureData contains mipmap data, the appropriate mipmap level will be selected.

dstx:int

the x offset (in pixels) relative to the lower-left corner of this texture where the update will be applied

dsty:int

the y offset (in pixels) relative to the lower-left corner of this texture where the update will be applied

srcx:int

the x offset (in pixels) relative to the lower-left corner of the supplied TextureData from which to fetch the update rectangle

srcy:int

the y offset (in pixels) relative to the lower-left corner of the supplied TextureData from which to fetch the update rectangle

width:int

the width (in pixels) of the rectangle to be updated

height:int

the height (in pixels) of the rectangle to be updated

Exceptions
GLException:
if no OpenGL context was current or if any OpenGL-related errors occurred
updateSubImageImplback to summary
private void updateSubImageImpl(final GL gl, final TextureData data, final int newTarget, final int mipmapLevel, int dstx, int dsty, int srcx, int srcy, int width, int height) throws GLException
updateTexCoordsback to summary
private void updateTexCoords()
validateTexIDback to summary
private boolean validateTexID(final GL gl, final boolean throwException)