Interface TextureBuilder

All Known Implementing Classes:
TextureBuilder.Abstract

public interface TextureBuilder
Texture builder utility class.

This class is used to generate textures in a "builder" way. Mostly useful for small applications and test applications, not necessarily for large enterprise applications that may employ better methods for texture loading and assembly.

All of these methods can be called outside of the graphics thread except create().

Depending on implementation version, some methods may not be supported or available, and will throw UnsupportedOperationException if so.

  • Method Details

    • setTargetType

      TextureBuilder setTargetType(TextureTargetType targetType)
      Sets the texture target type. By default, this is TextureTargetType.TEXTURE_2D.
      Parameters:
      targetType - the target type to use.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided target type is unavailable in this version.
    • setFiltering

      TextureBuilder setFiltering(TextureMinFilter minFilter, TextureMagFilter magFilter)
      Sets the minification and magnification filter on the texture. By default, this is TextureMinFilter.NEAREST for both.
      Parameters:
      minFilter - the minification filter to use.
      magFilter - the magnification filter to use.
      Returns:
      this builder.
    • setBorder

      TextureBuilder setBorder(int texels)
      Sets the border size on the texture in texels. By default, this is 0.
      Parameters:
      texels - the texel width.
      Returns:
      this builder.
    • setWrapping

      TextureBuilder setWrapping(TextureWrapType wrapS)
      Sets the wrapping on the texture. By default, all wrapping is TextureWrapType.TILE.
      Parameters:
      wrapS - the S-coordinate wrap type.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if the provided type is unavailable in this version.
    • setWrapping

      TextureBuilder setWrapping(TextureWrapType wrapS, TextureWrapType wrapT)
      Sets the wrapping on the texture. By default, all wrapping is TextureWrapType.TILE.
      Parameters:
      wrapS - the S-coordinate wrap type.
      wrapT - the T-coordinate wrap type.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if any of the provided types are unavailable in this version.
    • setWrapping

      TextureBuilder setWrapping(TextureWrapType wrapS, TextureWrapType wrapT, TextureWrapType wrapR)
      Sets the wrapping on the texture. By default, all wrapping is TextureWrapType.TILE.
      Parameters:
      wrapS - the S-coordinate wrap type.
      wrapT - the T-coordinate wrap type.
      wrapR - the R-coordinate wrap type.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if any of the provided types are unavailable in this version.
    • setCompressed

      TextureBuilder setCompressed(boolean enabled)
      Sets if the texture is stored in a compressed format. By default, this is false.
      Parameters:
      enabled - true to enable, false if disabled.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if this feature is unavailable in this version.
    • setAutoGenerateMipMaps

      TextureBuilder setAutoGenerateMipMaps(boolean autoGenerateMipMaps)
      Sets if this generator auto-generates mipmaps on or after data transfer. By default, this is false.
      Parameters:
      autoGenerateMipMaps - true to auto-generate mipmaps for this texture.
      Returns:
      this builder.
      Throws:
      UnsupportedOperationException - if this feature is unavailable in this version.
    • setAnisotropy

      TextureBuilder setAnisotropy(float anisotropy)
      Sets texture anisotropy level. By default, this is 1.0f.
      Parameters:
      anisotropy - the anisotropy level (1.0f or less = no anisotropy).
      Returns:
      this builder.
    • addTextureImage

      TextureBuilder addTextureImage(BufferedImage... images)
      Adds one or more textures to a mipmap level.

      Each image in the batch past the first is considered part of the depth dimension (an array of 4 images implies a depth of 4, height of 4 if 1D Array). If texture cube, then this expects 6 textures in the order: PX, NX, PY, NY, PZ, NZ.

      The first call to this is the topmost level, and each subsequent call is the next lower mipmap level. Every texture past the first one is ignored if mipmap auto-generation is enabled.

      Parameters:
      images - the image to add at this level.
      Returns:
      this builder.
      Throws:
      GraphicsException - if images is length 0, or no images were provided.
    • create

      OGLTexture create()
      Creates this texture.
      Returns:
      the texture object created.
      Throws:
      GraphicsException - if the texture could not be created.