public class BasicWWTexture extends java.lang.Object implements WWTexture
BufferedImage
.
The interface contains a method, isTextureInitializationFailed()
to determine whether the instance failed to
convert an image source to a texture. If such a failure occurs, the method returns true and no further attempts are
made to create the texture.
This class retrieves its image source immediately during a call to bind(DrawContext)
or applyInternalTransform(DrawContext)
.
LazilyLoadedTexture
Modifier and Type | Field and Description |
---|---|
protected java.lang.Integer |
height |
protected com.jogamp.opengl.util.texture.TextureCoords |
texCoords |
protected boolean |
textureInitializationFailed |
protected java.lang.Integer |
width |
Constructor and Description |
---|
BasicWWTexture(java.lang.Object imageSource)
Constructs a texture object.
|
BasicWWTexture(java.lang.Object imageSource,
boolean useMipMaps)
Constructs a texture object from an image source.
|
Modifier and Type | Method and Description |
---|---|
void |
applyInternalTransform(DrawContext dc)
Applies any necessary transformations to the texture prior to its being rendered.
|
boolean |
bind(DrawContext dc)
Makes this texture the current texture for rendering.
|
int |
getHeight(DrawContext dc)
Returns the texture's height
|
java.lang.Object |
getImageSource()
Returns the texture's image source.
|
com.jogamp.opengl.util.texture.TextureCoords |
getTexCoords()
Returns the texture's texture coordinates, which may be other than [0,0],[1,1] if the texture size is not a power
of two or the texture must be flipped when rendered.
|
protected com.jogamp.opengl.util.texture.Texture |
getTexture(DrawContext dc,
boolean initialize) |
protected com.jogamp.opengl.util.texture.Texture |
getTextureFromCache(DrawContext dc) |
int |
getWidth(DrawContext dc)
Returns the texture's width.
|
protected void |
initialize(java.lang.Object imageSource,
boolean useMipMaps) |
protected com.jogamp.opengl.util.texture.Texture |
initializeTexture(DrawContext dc,
java.lang.Object imageSource) |
boolean |
isTextureCurrent(DrawContext dc)
Indicates whether the texture is currently available for use without regenerating it from its image source.
|
boolean |
isTextureInitializationFailed()
Indicates whether an attempt to initialize the texture failed, which occurs when the image source is a
non-existent image file or for other reasons specific to the image source.
|
boolean |
isUseAnisotropy()
Indicates whether texture anisotropy is applied to the texture when rendered.
|
boolean |
isUseMipMaps()
Indicates whether the texture creates and uses mipmaps.
|
void |
setUseAnisotropy(boolean useAnisotropy)
Specifies whether texture anisotropy is applied to the texture when rendered.
|
protected java.lang.Integer height
protected com.jogamp.opengl.util.texture.TextureCoords texCoords
protected boolean textureInitializationFailed
protected java.lang.Integer width
public BasicWWTexture(java.lang.Object imageSource)
The texture's image source is opened, if a file, only when the texture is displayed. If the texture is not displayed the image source is not read.
imageSource
- the source of the image, either a file path String
or a BufferedImage
.java.lang.IllegalArgumentException
- if the imageSource
is null.public BasicWWTexture(java.lang.Object imageSource, boolean useMipMaps)
The texture's image source is opened, if a file, only when the texture is displayed. If the texture is not displayed the image source is not read.
imageSource
- the source of the image, either a file path String
or a BufferedImage
.useMipMaps
- Indicates whether to generate and use mipmaps for the image.java.lang.IllegalArgumentException
- if the imageSource
is null.public void applyInternalTransform(DrawContext dc)
WWTexture
applyInternalTransform
in interface WWTexture
dc
- the current draw context.public boolean bind(DrawContext dc)
WWTexture
If the implementing instance's internal texture has not been created from its image source, the implementing class determines when the texture is retrieved and available.
If a texture cannot be created from its image source it cannot be bound. This method returns an indication of whether the texture was bound or was not bound due to a failure during creation.
public int getHeight(DrawContext dc)
WWTexture
public java.lang.Object getImageSource()
WWTexture
getImageSource
in interface WWTexture
public com.jogamp.opengl.util.texture.TextureCoords getTexCoords()
WWTexture
getTexCoords
in interface WWTexture
protected com.jogamp.opengl.util.texture.Texture getTexture(DrawContext dc, boolean initialize)
protected com.jogamp.opengl.util.texture.Texture getTextureFromCache(DrawContext dc)
public int getWidth(DrawContext dc)
WWTexture
protected void initialize(java.lang.Object imageSource, boolean useMipMaps)
protected com.jogamp.opengl.util.texture.Texture initializeTexture(DrawContext dc, java.lang.Object imageSource)
public boolean isTextureCurrent(DrawContext dc)
WWTexture
isTextureCurrent
in interface WWTexture
dc
- the current draw contextpublic boolean isTextureInitializationFailed()
WWTexture
isTextureInitializationFailed
in interface WWTexture
public boolean isUseAnisotropy()
public boolean isUseMipMaps()
public void setUseAnisotropy(boolean useAnisotropy)
useAnisotropy
- true if anisotropy is to be applied, otherwise false.