Class BasicWWTexture
- java.lang.Object
-
- gov.nasa.worldwind.render.BasicWWTexture
-
- All Implemented Interfaces:
WWTexture
public class BasicWWTexture extends java.lang.Object implements WWTexture
Basic implementation of a texture derived from an image source such as an image file or aBufferedImage.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)orapplyInternalTransform(DrawContext).- See Also:
LazilyLoadedTexture
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Integerheightprotected com.jogamp.opengl.util.texture.TextureCoordstexCoordsprotected booleantextureInitializationFailedprotected java.lang.Integerwidth
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyInternalTransform(DrawContext dc)Applies any necessary transformations to the texture prior to its being rendered.booleanbind(DrawContext dc)Makes this texture the current texture for rendering.intgetHeight(DrawContext dc)Returns the texture's heightjava.lang.ObjectgetImageSource()Returns the texture's image source.com.jogamp.opengl.util.texture.TextureCoordsgetTexCoords()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.TexturegetTexture(DrawContext dc, boolean initialize)protected com.jogamp.opengl.util.texture.TexturegetTextureFromCache(DrawContext dc)intgetWidth(DrawContext dc)Returns the texture's width.protected voidinitialize(java.lang.Object imageSource, boolean useMipMaps)protected com.jogamp.opengl.util.texture.TextureinitializeTexture(DrawContext dc, java.lang.Object imageSource)booleanisTextureCurrent(DrawContext dc)Indicates whether the texture is currently available for use without regenerating it from its image source.booleanisTextureInitializationFailed()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.booleanisUseAnisotropy()Indicates whether texture anisotropy is applied to the texture when rendered.booleanisUseMipMaps()Indicates whether the texture creates and uses mipmaps.voidsetUseAnisotropy(boolean useAnisotropy)Specifies whether texture anisotropy is applied to the texture when rendered.
-
-
-
Constructor Detail
-
BasicWWTexture
public BasicWWTexture(java.lang.Object imageSource, boolean useMipMaps)Constructs a texture object from an image source.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.
- Parameters:
imageSource- the source of the image, either a file pathStringor aBufferedImage.useMipMaps- Indicates whether to generate and use mipmaps for the image.- Throws:
java.lang.IllegalArgumentException- if theimageSourceis null.
-
BasicWWTexture
public BasicWWTexture(java.lang.Object imageSource)
Constructs a texture object.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.
- Parameters:
imageSource- the source of the image, either a file pathStringor aBufferedImage.- Throws:
java.lang.IllegalArgumentException- if theimageSourceis null.
-
-
Method Detail
-
initialize
protected void initialize(java.lang.Object imageSource, boolean useMipMaps)
-
getImageSource
public java.lang.Object getImageSource()
Description copied from interface:WWTextureReturns the texture's image source.- Specified by:
getImageSourcein interfaceWWTexture- Returns:
- the texture's image source.
-
getWidth
public int getWidth(DrawContext dc)
Description copied from interface:WWTextureReturns the texture's width.
-
getHeight
public int getHeight(DrawContext dc)
Description copied from interface:WWTextureReturns the texture's height
-
isUseMipMaps
public boolean isUseMipMaps()
Indicates whether the texture creates and uses mipmaps.- Returns:
- true if mipmaps are used, false if not.
-
getTexCoords
public com.jogamp.opengl.util.texture.TextureCoords getTexCoords()
Description copied from interface:WWTextureReturns 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.- Specified by:
getTexCoordsin interfaceWWTexture- Returns:
- returns the texture's texture coordinates.
-
isTextureCurrent
public boolean isTextureCurrent(DrawContext dc)
Description copied from interface:WWTextureIndicates whether the texture is currently available for use without regenerating it from its image source.- Specified by:
isTextureCurrentin interfaceWWTexture- Parameters:
dc- the current draw context- Returns:
- true if the texture is available and consistent with its image source, otherwise false.
-
isUseAnisotropy
public boolean isUseAnisotropy()
Indicates whether texture anisotropy is applied to the texture when rendered.- Returns:
- useAnisotropy true if anisotropy is to be applied, otherwise false.
-
setUseAnisotropy
public void setUseAnisotropy(boolean useAnisotropy)
Specifies whether texture anisotropy is applied to the texture when rendered.- Parameters:
useAnisotropy- true if anisotropy is to be applied, otherwise false.
-
isTextureInitializationFailed
public boolean isTextureInitializationFailed()
Description copied from interface:WWTextureIndicates 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.- Specified by:
isTextureInitializationFailedin interfaceWWTexture- Returns:
- true if texture initialization failed, otherwise false.
-
getTexture
protected com.jogamp.opengl.util.texture.Texture getTexture(DrawContext dc, boolean initialize)
-
getTextureFromCache
protected com.jogamp.opengl.util.texture.Texture getTextureFromCache(DrawContext dc)
-
bind
public boolean bind(DrawContext dc)
Description copied from interface:WWTextureMakes this texture the current texture for rendering.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.
-
applyInternalTransform
public void applyInternalTransform(DrawContext dc)
Description copied from interface:WWTextureApplies any necessary transformations to the texture prior to its being rendered. A common transformation is mapping texture coordinates from a flipped or non-square state to conventionally oriented OpenGL values.- Specified by:
applyInternalTransformin interfaceWWTexture- Parameters:
dc- the current draw context.
-
initializeTexture
protected com.jogamp.opengl.util.texture.Texture initializeTexture(DrawContext dc, java.lang.Object imageSource)
-
-