Class Texture

java.lang.Object
com.ardor3d.image.Texture
All Implemented Interfaces:
Savable
Direct Known Subclasses:
Texture1D, Texture2D, Texture3D, TextureCubeMap

public abstract class Texture extends Object implements Savable
Texture defines a texture object to be used to display an image on a piece of geometry. The image to be displayed is defined by the Image class. All attributes required for texture mapping are contained within this class. This includes mipmapping if desired, magnificationFilter options, apply options and correction options. Default values are as follows: minificationFilter - NearestNeighborNoMipMaps, magnificationFilter - NearestNeighbor, wrap - EdgeClamp on S,T and R, apply - Modulate, environment - None.
See Also:
  • Field Details

    • DEFAULT_STORE_IMAGE

      public static boolean DEFAULT_STORE_IMAGE
  • Constructor Details

    • Texture

      public Texture()
      Constructor instantiates a new Texture object with default attributes.
  • Method Details

    • setConstantColor

      public void setConstantColor(ReadOnlyColorRGBA color)
      sets a color that is used with CombinerSource.Constant
      Parameters:
      color - the new constant color (the default is ColorRGBA.BLACK_NO_ALPHA)
    • setConstantColor

      public void setConstantColor(float red, float green, float blue, float alpha)
      sets a color that is used with CombinerSource.Constant
      Parameters:
      red - the red value
      green - the green value
      blue - the blue value
      alpha - the alpha value
    • setBorderColor

      public void setBorderColor(ReadOnlyColorRGBA color)
      sets the color used when texture operations encounter the border of a texture.
      Parameters:
      color - the new border color (the default is ColorRGBA.BLACK_NO_ALPHA)
    • setBorderColor

      public void setBorderColor(float red, float green, float blue, float alpha)
      sets the color used when texture operations encounter the border of a texture.
      Parameters:
      red - the red value
      green - the green value
      blue - the blue value
      alpha - the alpha value
    • getMinificationFilter

      public Texture.MinificationFilter getMinificationFilter()
      Returns:
      the MinificationFilterMode of this texture.
    • setMinificationFilter

      public void setMinificationFilter(Texture.MinificationFilter minificationFilter)
      Parameters:
      minificationFilter - the new MinificationFilterMode for this texture.
      Throws:
      IllegalArgumentException - if minificationFilter is null
    • getMagnificationFilter

      public Texture.MagnificationFilter getMagnificationFilter()
      Returns:
      the MagnificationFilterMode of this texture.
    • setMagnificationFilter

      public void setMagnificationFilter(Texture.MagnificationFilter magnificationFilter)
      Parameters:
      magnificationFilter - the new MagnificationFilter for this texture.
      Throws:
      IllegalArgumentException - if magnificationFilter is null
    • setApply

      public void setApply(Texture.ApplyMode apply)
      setApply sets the apply mode for this texture.
      Parameters:
      apply - the apply mode for this texture.
      Throws:
      IllegalArgumentException - if apply is null
    • setImage

      public void setImage(Image image)
      setImage sets the image object that defines the texture.
      Parameters:
      image - the image that defines the texture.
    • getTextureIdForContext

      public int getTextureIdForContext(Object glContext)
      Parameters:
      glContext - the object representing the OpenGL context this texture belongs to. See RenderContext.getGlContextRep()
      Returns:
      the texture id of this texture in the given context. If the texture is not found in the given context, 0 is returned.
    • getTextureIdForContextAsInteger

      public Integer getTextureIdForContextAsInteger(Object glContext)
      Parameters:
      glContext - the object representing the OpenGL context this texture belongs to. See RenderContext.getGlContextRep()
      Returns:
      the texture id of this texture in the given context as an Integer object. If the texture is not found in the given context, a 0 integer is returned.
    • setTextureIdForContext

      public void setTextureIdForContext(Object glContext, int textureId)
      Sets the id for this texture in regards to the given OpenGL context.
      Parameters:
      glContext - the object representing the OpenGL context this texture belongs to. See RenderContext.getGlContextRep()
      textureId - the texture id of this texture. To be valid, this must be greater than 0.
      Throws:
      IllegalArgumentException - if textureId is less than or equal to 0.
    • removeFromIdCache

      public void removeFromIdCache(Object glContext)

      Removes any texture id for this texture for the given OpenGL context.

      Note: This does not remove the texture from the card and is provided for use by code that does remove textures from the card.

      Parameters:
      glContext - the object representing the OpenGL context this texture belongs to. See RenderContext.getGlContextRep()
    • getImage

      public Image getImage()
      Returns:
      the image data that makes up this texture. If no image data has been set, this will return null.
    • getApply

      public Texture.ApplyMode getApply()
      Returns:
      the apply mode of the texture.
    • getConstantColor

      public ReadOnlyColorRGBA getConstantColor()
      Returns:
      the color set to be used with CombinerSource.Constant for this texture (as applicable). (the default is ColorRGBA.BLACK_NO_ALPHA)
    • getBorderColor

      public ReadOnlyColorRGBA getBorderColor()
      Returns:
      the color to be used for border operations. (the default is ColorRGBA.BLACK_NO_ALPHA)
    • setWrap

      public abstract void setWrap(Texture.WrapAxis axis, Texture.WrapMode mode)
      Sets the wrap mode of this texture for a particular axis.
      Parameters:
      axis - the texture axis to define a wrapmode on.
      mode - the wrap mode for the given axis of the texture.
      Throws:
      IllegalArgumentException - if axis or mode are null or invalid for this type of texture
    • setWrap

      public abstract void setWrap(Texture.WrapMode mode)
      Sets the wrap mode of this texture for all axis.
      Parameters:
      mode - the wrap mode for the given axis of the texture.
      Throws:
      IllegalArgumentException - if mode is null or invalid for this type of texture
    • getWrap

      public abstract Texture.WrapMode getWrap(Texture.WrapAxis axis)
      Parameters:
      axis - the axis to return for
      Returns:
      the wrap mode for the given coordinate axis on this texture.
      Throws:
      IllegalArgumentException - if axis is null or invalid for this type of texture
    • getType

      public abstract Texture.Type getType()
      Returns:
      the Texture.Type enum value of this Texture object.
    • getCombineFuncRGB

      public Texture.CombinerFunctionRGB getCombineFuncRGB()
      Returns:
      the combineFuncRGB.
    • setCombineFuncRGB

      public void setCombineFuncRGB(Texture.CombinerFunctionRGB combineFuncRGB)
      Parameters:
      combineFuncRGB - The combineFuncRGB to set.
      Throws:
      IllegalArgumentException - if combineFuncRGB is null
    • getCombineOp0Alpha

      public Texture.CombinerOperandAlpha getCombineOp0Alpha()
      Returns:
      Returns the combineOp0Alpha.
    • setCombineOp0Alpha

      public void setCombineOp0Alpha(Texture.CombinerOperandAlpha combineOp0Alpha)
      Parameters:
      combineOp0Alpha - The combineOp0Alpha to set.
      Throws:
      IllegalArgumentException - if combineOp0Alpha is null
    • getCombineOp0RGB

      public Texture.CombinerOperandRGB getCombineOp0RGB()
      Returns:
      Returns the combineOp0RGB.
    • setCombineOp0RGB

      public void setCombineOp0RGB(Texture.CombinerOperandRGB combineOp0RGB)
      Parameters:
      combineOp0RGB - The combineOp0RGB to set.
      Throws:
      IllegalArgumentException - if combineOp0RGB is null
    • getCombineOp1Alpha

      public Texture.CombinerOperandAlpha getCombineOp1Alpha()
      Returns:
      Returns the combineOp1Alpha.
    • setCombineOp1Alpha

      public void setCombineOp1Alpha(Texture.CombinerOperandAlpha combineOp1Alpha)
      Parameters:
      combineOp1Alpha - The combineOp1Alpha to set.
      Throws:
      IllegalArgumentException - if combineOp1Alpha is null
    • getCombineOp1RGB

      public Texture.CombinerOperandRGB getCombineOp1RGB()
      Returns:
      Returns the combineOp1RGB.
    • setCombineOp1RGB

      public void setCombineOp1RGB(Texture.CombinerOperandRGB combineOp1RGB)
      Parameters:
      combineOp1RGB - The combineOp1RGB to set.
      Throws:
      IllegalArgumentException - if combineOp1RGB is null
    • getCombineOp2Alpha

      public Texture.CombinerOperandAlpha getCombineOp2Alpha()
      Returns:
      Returns the combineOp2Alpha.
    • setCombineOp2Alpha

      public void setCombineOp2Alpha(Texture.CombinerOperandAlpha combineOp2Alpha)
      Parameters:
      combineOp2Alpha - The combineOp2Alpha to set.
      Throws:
      IllegalArgumentException - if combineOp2Alpha is null
    • getCombineOp2RGB

      public Texture.CombinerOperandRGB getCombineOp2RGB()
      Returns:
      Returns the combineOp2RGB.
    • setCombineOp2RGB

      public void setCombineOp2RGB(Texture.CombinerOperandRGB combineOp2RGB)
      Parameters:
      combineOp2RGB - The combineOp2RGB to set.
      Throws:
      IllegalArgumentException - if combineOp2RGB is null
    • getCombineScaleAlpha

      public Texture.CombinerScale getCombineScaleAlpha()
      Returns:
      Returns the combineScaleAlpha.
    • setCombineScaleAlpha

      public void setCombineScaleAlpha(Texture.CombinerScale combineScaleAlpha)
      Parameters:
      combineScaleAlpha - The combineScaleAlpha to set.
      Throws:
      IllegalArgumentException - if combineScaleAlpha is null
    • getCombineScaleRGB

      public Texture.CombinerScale getCombineScaleRGB()
      Returns:
      Returns the combineScaleRGB.
    • setCombineScaleRGB

      public void setCombineScaleRGB(Texture.CombinerScale combineScaleRGB)
      Parameters:
      combineScaleRGB - The combineScaleRGB to set.
      Throws:
      IllegalArgumentException - if combineScaleRGB is null
    • getCombineSrc0Alpha

      public Texture.CombinerSource getCombineSrc0Alpha()
      Returns:
      Returns the combineSrc0Alpha.
    • setCombineSrc0Alpha

      public void setCombineSrc0Alpha(Texture.CombinerSource combineSrc0Alpha)
      Parameters:
      combineSrc0Alpha - The combineSrc0Alpha to set.
      Throws:
      IllegalArgumentException - if combineSrc0Alpha is null
    • getCombineSrc0RGB

      public Texture.CombinerSource getCombineSrc0RGB()
      Returns:
      Returns the combineSrc0RGB.
    • setCombineSrc0RGB

      public void setCombineSrc0RGB(Texture.CombinerSource combineSrc0RGB)
      Parameters:
      combineSrc0RGB - The combineSrc0RGB to set.
      Throws:
      IllegalArgumentException - if combineSrc0RGB is null
    • getCombineSrc1Alpha

      public Texture.CombinerSource getCombineSrc1Alpha()
      Returns:
      Returns the combineSrc1Alpha.
    • setCombineSrc1Alpha

      public void setCombineSrc1Alpha(Texture.CombinerSource combineSrc1Alpha)
      Parameters:
      combineSrc1Alpha - The combineSrc1Alpha to set.
      Throws:
      IllegalArgumentException - if combineSrc1Alpha is null
    • getCombineSrc1RGB

      public Texture.CombinerSource getCombineSrc1RGB()
      Returns:
      Returns the combineSrc1RGB.
    • setCombineSrc1RGB

      public void setCombineSrc1RGB(Texture.CombinerSource combineSrc1RGB)
      Parameters:
      combineSrc1RGB - The combineSrc1RGB to set.
      Throws:
      IllegalArgumentException - if combineSrc1RGB is null
    • getCombineSrc2Alpha

      public Texture.CombinerSource getCombineSrc2Alpha()
      Returns:
      Returns the combineSrc2Alpha.
    • setCombineSrc2Alpha

      public void setCombineSrc2Alpha(Texture.CombinerSource combineSrc2Alpha)
      Parameters:
      combineSrc2Alpha - The combineSrc2Alpha to set.
      Throws:
      IllegalArgumentException - if combineSrc2Alpha is null
    • getCombineSrc2RGB

      public Texture.CombinerSource getCombineSrc2RGB()
      Returns:
      Returns the combineSrc2RGB.
    • setCombineSrc2RGB

      public void setCombineSrc2RGB(Texture.CombinerSource combineSrc2RGB)
      Parameters:
      combineSrc2RGB - The combineSrc2RGB to set.
      Throws:
      IllegalArgumentException - if combineSrc2RGB is null
    • getCombineFuncAlpha

      public Texture.CombinerFunctionAlpha getCombineFuncAlpha()
      Returns:
      Returns the combineFuncAlpha.
    • setCombineFuncAlpha

      public void setCombineFuncAlpha(Texture.CombinerFunctionAlpha combineFuncAlpha)
      Parameters:
      combineFuncAlpha - The combineFuncAlpha to set.
      Throws:
      IllegalArgumentException - if combineFuncAlpha is null
    • setEnvironmentalMapMode

      public void setEnvironmentalMapMode(Texture.EnvironmentalMapMode envMapMode)
      Parameters:
      envMapMode - the environmental map mode to set
      Throws:
      IllegalArgumentException - if envMapMode is null
    • getEnvironmentalMapMode

      public Texture.EnvironmentalMapMode getEnvironmentalMapMode()
    • getEnvPlaneS

      public ReadOnlyVector4 getEnvPlaneS()
    • setEnvPlaneS

      public void setEnvPlaneS(ReadOnlyVector4 plane)
    • getEnvPlaneT

      public ReadOnlyVector4 getEnvPlaneT()
    • setEnvPlaneT

      public void setEnvPlaneT(ReadOnlyVector4 plane)
    • getEnvPlaneR

      public ReadOnlyVector4 getEnvPlaneR()
    • setEnvPlaneR

      public void setEnvPlaneR(ReadOnlyVector4 plane)
    • getEnvPlaneQ

      public ReadOnlyVector4 getEnvPlaneQ()
    • setEnvPlaneQ

      public void setEnvPlaneQ(ReadOnlyVector4 plane)
    • getAnisotropicFilterPercent

      public float getAnisotropicFilterPercent()
      Returns:
      the anisotropic filtering level for this texture as a percentage (0.0 - 1.0)
    • setAnisotropicFilterPercent

      public void setAnisotropicFilterPercent(float percent)
      Parameters:
      percent - the anisotropic filtering level for this texture as a percentage (0.0 - 1.0)
    • getLodBias

      public float getLodBias()
      Returns:
      the lodBias for this texture
    • setLodBias

      public void setLodBias(float bias)
      Parameters:
      bias - the lod bias for this texture. The default is 0.
    • setTextureKey

      public void setTextureKey(TextureKey tkey)
    • getTextureKey

      public TextureKey getTextureKey()
    • setTextureStoreFormat

      public void setTextureStoreFormat(TextureStoreFormat storeFormat)
    • setRenderedTexturePixelDataType

      public void setRenderedTexturePixelDataType(PixelDataType type)
    • getRenderedTexturePixelDataType

      public PixelDataType getRenderedTexturePixelDataType()
    • getTextureStoreFormat

      public TextureStoreFormat getTextureStoreFormat()
    • isStoreImage

      public boolean isStoreImage()
    • setStoreImage

      public void setStoreImage(boolean store)
    • hasBorder

      public boolean hasBorder()
    • setHasBorder

      public void setHasBorder(boolean hasBorder)
    • getDepthCompareFunc

      public Texture.DepthTextureCompareFunc getDepthCompareFunc()
      Get the depth texture compare function
      Returns:
      The depth texture compare function
    • setDepthCompareFunc

      public void setDepthCompareFunc(Texture.DepthTextureCompareFunc depthCompareFunc)
      Set the depth texture compare function
      Parameters:
      depthCompareFunc - The depth texture compare function
    • getDepthMode

      public Texture.DepthTextureMode getDepthMode()
      Get the depth texture apply mode
      Returns:
      The depth texture apply mode
    • setDepthMode

      public void setDepthMode(Texture.DepthTextureMode depthMode)
      Set the depth texture apply mode
      Parameters:
      depthMode - The depth texture apply mode
    • getDepthCompareMode

      public Texture.DepthTextureCompareMode getDepthCompareMode()
      Get the depth texture compare mode
      Returns:
      The depth texture compare mode
    • setDepthCompareMode

      public void setDepthCompareMode(Texture.DepthTextureCompareMode depthCompareMode)
      Set the depth texture compare mode
      Parameters:
      depthCompareMode - The depth texture compare mode
    • setDirty

      public void setDirty()
    • isDirty

      public boolean isDirty(Object glContext)
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • createSimpleClone

      public abstract Texture createSimpleClone()
    • createSimpleClone

      public Texture createSimpleClone(Texture rVal)
      Retrieve a basic clone of this Texture (ie, clone everything but the image data, which is shared)
      Parameters:
      rVal - the texture to clone
      Returns:
      Texture
    • getTextureMatrix

      public ReadOnlyMatrix4 getTextureMatrix()
    • setTextureMatrix

      public void setTextureMatrix(ReadOnlyMatrix4 matrix)
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • getClassTag

      public Class<? extends Texture> getClassTag()
      Specified by:
      getClassTag in interface Savable
    • getTextureBaseLevel

      public int getTextureBaseLevel()
    • setTextureBaseLevel

      public void setTextureBaseLevel(int textureBaseLevel)
    • getTextureMaxLevel

      public int getTextureMaxLevel()
    • setTextureMaxLevel

      public void setTextureMaxLevel(int textureMaxLevel)