Interface TextureBuilder
- All Known Implementing Classes:
TextureBuilder.Abstract
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classTextureBuilder.Abstract<GL extends OGLGraphics>Texture builder utility class. -
Method Summary
Modifier and TypeMethodDescriptionaddTextureImage(BufferedImage... images) Adds one or more textures to a mipmap level.create()Creates this texture.setAnisotropy(float anisotropy) Sets texture anisotropy level.setAutoGenerateMipMaps(boolean autoGenerateMipMaps) Sets if this generator auto-generates mipmaps on or after data transfer.setBorder(int texels) Sets the border size on the texture in texels.setCompressed(boolean enabled) Sets if the texture is stored in a compressed format.setFiltering(TextureMinFilter minFilter, TextureMagFilter magFilter) Sets the minification and magnification filter on the texture.setTargetType(TextureTargetType targetType) Sets the texture target type.setWrapping(TextureWrapType wrapS) Sets the wrapping on the texture.setWrapping(TextureWrapType wrapS, TextureWrapType wrapT) Sets the wrapping on the texture.setWrapping(TextureWrapType wrapS, TextureWrapType wrapT, TextureWrapType wrapR) Sets the wrapping on the texture.
-
Method Details
-
setTargetType
Sets the texture target type. By default, this isTextureTargetType.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
Sets the minification and magnification filter on the texture. By default, this isTextureMinFilter.NEARESTfor both.- Parameters:
minFilter- the minification filter to use.magFilter- the magnification filter to use.- Returns:
- this builder.
-
setBorder
Sets the border size on the texture in texels. By default, this is0.- Parameters:
texels- the texel width.- Returns:
- this builder.
-
setWrapping
Sets the wrapping on the texture. By default, all wrapping isTextureWrapType.TILE.- Parameters:
wrapS- the S-coordinate wrap type.- Returns:
- this builder.
- Throws:
UnsupportedOperationException- if the provided type is unavailable in this version.
-
setWrapping
Sets the wrapping on the texture. By default, all wrapping isTextureWrapType.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
Sets the wrapping on the texture. By default, all wrapping isTextureWrapType.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
Sets if the texture is stored in a compressed format. By default, this isfalse.- Parameters:
enabled- true to enable, false if disabled.- Returns:
- this builder.
- Throws:
UnsupportedOperationException- if this feature is unavailable in this version.
-
setAutoGenerateMipMaps
Sets if this generator auto-generates mipmaps on or after data transfer. By default, this isfalse.- Parameters:
autoGenerateMipMaps- true to auto-generate mipmaps for this texture.- Returns:
- this builder.
- Throws:
UnsupportedOperationException- if this feature is unavailable in this version.
-
setAnisotropy
Sets texture anisotropy level. By default, this is1.0f.- Parameters:
anisotropy- the anisotropy level (1.0f or less = no anisotropy).- Returns:
- this builder.
-
addTextureImage
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.
-