-
public class TextureTexture
The
Textureclass supports:- 2D textures
- 3D textures
- Cube maps
- mip mapping
Textureobject is created using the Texture.Builder and destroyed by calling destroyTexture. They're bound using setParameter.Engine engine = Engine.create(); Material material = new Material.Builder() .payload( ... ) .build(ending); MaterialInstance mi = material.getDefaultInstance(); Texture texture = new Texture.Builder() .width(64) .height(64) .build(engine); texture.setImage(engine, 0, new Texture.PixelBufferDescriptor( ... )); mi.setParameter("parameterName", texture, new TextureSampler());
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumTexture.SamplerType of sampler
public enumTexture.InternalFormatInternal texel formats
These formats are used to specify a texture's internal storage format.
Enumerants syntax format[components][size][type]components: List of stored components by this formatsize: Size in bit of each componenttype: Type this format is stored asSpecial color formatsThere are a few special color formats that don't follow the convention above:Compressed texture formatsMany compressed texture formats are supported as well, which include (but are not limited to)the following list:public enumTexture.CompressedFormatCompressed data types for use with PixelBufferDescriptor
public enumTexture.CubemapFaceCubemap faces
public enumTexture.FormatPixel color format
public enumTexture.TypePixel data type
public enumTexture.SwizzleTexture swizzling channels
public classTexture.PixelBufferDescriptorA descriptor to an image in main memory, typically used to transfer image data from the CPUto the GPU.
A
PixelBufferDescriptorowns the memory buffer it references,thereforePixelBufferDescriptorcannot be copied, but can be moved.PixelBufferDescriptorreleases ownership of the memory-buffer when it'sdestroyed.public classTexture.PrefilterOptionsOptions of generatePrefilterMipmap
public classTexture.BuilderUse
Builderto construct aTextureobject instance.public classTexture.UsageA bitmask to specify how the texture will be used.
-
Field Summary
Fields Modifier and Type Field Description public final static intBASE_LEVEL
-
Constructor Summary
Constructors Constructor Description Texture(long nativeTexture)
-
Method Summary
Modifier and Type Method Description static booleanisTextureFormatSupported(@NonNull() Engine engine, @NonNull() Texture.InternalFormat format)Checks whether a given format is supported for texturing in this Engine.This depends on the selected backend. static booleanisTextureSwizzleSupported(@NonNull() Engine engine)Checks whether texture swizzling is supported in this Engine.This depends on the selected backend. intgetWidth(@IntRange(from = 0) int level)Queries the width of a given level of this texture. intgetHeight(@IntRange(from = 0) int level)Queries the height of a given level of this texture. intgetDepth(@IntRange(from = 0) int level)Queries the number of layers of given level of this texture has. intgetLevels()Texture.SamplergetTarget()Texture.InternalFormatgetFormat()voidsetImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @NonNull() Texture.PixelBufferDescriptor buffer)setImageis used to modify the whole content of the texture from a CPU-buffer.voidsetImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset, @IntRange(from = 0) int width, @IntRange(from = 0) int height, @NonNull() Texture.PixelBufferDescriptor buffer)setImageis used to modify a sub-region of the texture from a CPU-buffer.voidsetImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset, @IntRange(from = 0) int zoffset, @IntRange(from = 0) int width, @IntRange(from = 0) int height, @IntRange(from = 0) int depth, @NonNull() Texture.PixelBufferDescriptor buffer)setImageis used to modify a sub-region of a 3D texture, 2D texture array orcubemap from a CPU-buffer.voidsetImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @NonNull() Texture.PixelBufferDescriptor buffer, @NonNull() @Size(min = 6) Array<int> faceOffsetsInBytes)setImageis used to specify all six images of a cubemap level andfollows exactly the OpenGL conventionsThisTextureinstance must useSAMPLER_CUBEMAP.voidsetExternalImage(@NonNull() Engine engine, long eglImage)Specifies the external image to associate with this Texture.voidsetExternalStream(@NonNull() Engine engine, @NonNull() Stream stream)Specifies the external stream to associate with this Texture.voidgenerateMipmaps(@NonNull() Engine engine)Generates all the mipmap levels automatically. voidgeneratePrefilterMipmap(@NonNull() Engine engine, @NonNull() Texture.PixelBufferDescriptor buffer, @NonNull() @Size(min = 6) Array<int> faceOffsetsInBytes, Texture.PrefilterOptions options)Creates a reflection map from an environment map. longgetNativeObject()-
-
Method Detail
-
isTextureFormatSupported
static boolean isTextureFormatSupported(@NonNull() Engine engine, @NonNull() Texture.InternalFormat format)
Checks whether a given format is supported for texturing in this Engine.This depends on the selected backend.
- Parameters:
engine- Engine to test the InternalFormat againstformat- format to check
-
isTextureSwizzleSupported
static boolean isTextureSwizzleSupported(@NonNull() Engine engine)
Checks whether texture swizzling is supported in this Engine.This depends on the selected backend.
- Parameters:
engine- Engine
-
getWidth
int getWidth(@IntRange(from = 0) int level)
Queries the width of a given level of this texture.
- Parameters:
level- to query the with of.
-
getHeight
int getHeight(@IntRange(from = 0) int level)
Queries the height of a given level of this texture.
- Parameters:
level- to query the height of.
-
getDepth
int getDepth(@IntRange(from = 0) int level)
Queries the number of layers of given level of this texture has.
- Parameters:
level- to query the number of layers of.
-
getLevels
int getLevels()
-
getTarget
@NonNull() Texture.Sampler getTarget()
-
getFormat
@NonNull() Texture.InternalFormat getFormat()
-
setImage
void setImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @NonNull() Texture.PixelBufferDescriptor buffer)
setImageis used to modify the whole content of the texture from a CPU-buffer.This
This is equivalent to calling:Textureinstance must use SAMPLER_2D orSAMPLER_EXTERNAL. If the later is specifiedand external textures are supported by the driver implementation,this method will have no effect, otherwise it will behave as if thetexture was specified with SAMPLER_2D.setImage(engine, level, 0, 0, getWidth(level), getHeight(level), buffer)- Parameters:
engine- Engine this texture is associated to.level- Level to set the image for.buffer- Client-side buffer containing the image to set.
-
setImage
void setImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset, @IntRange(from = 0) int width, @IntRange(from = 0) int height, @NonNull() Texture.PixelBufferDescriptor buffer)
setImageis used to modify a sub-region of the texture from a CPU-buffer.This
Textureinstance must use SAMPLER_2D orSAMPLER_EXTERNAL. If the later is specifiedand external textures are supported by the driver implementation,this method will have no effect, otherwise it will behave as if thetexture was specified with SAMPLER_2D.- Parameters:
engine- Engine this texture is associated to.level- Level to set the image for.xoffset- x-offset in texel of the region to modifyyoffset- y-offset in texel of the region to modifywidth- width in texel of the region to modifyheight- height in texel of the region to modifybuffer- Client-side buffer containing the image to set.
-
setImage
void setImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset, @IntRange(from = 0) int zoffset, @IntRange(from = 0) int width, @IntRange(from = 0) int height, @IntRange(from = 0) int depth, @NonNull() Texture.PixelBufferDescriptor buffer)
setImageis used to modify a sub-region of a 3D texture, 2D texture array orcubemap from a CPU-buffer. Cubemaps are treated like a 2D array of six layers.This
Textureinstance must use SAMPLER_2D_ARRAY,SAMPLER_3D or SAMPLER_CUBEMAP.- Parameters:
engine- Engine this texture is associated to.level- Level to set the image for.xoffset- x-offset in texel of the region to modifyyoffset- y-offset in texel of the region to modifyzoffset- z-offset in texel of the region to modifywidth- width in texel of the region to modifyheight- height in texel of the region to modifydepth- depth in texel or index of the region to modifybuffer- Client-side buffer containing the image to set.
-
setImage
@Deprecated() void setImage(@NonNull() Engine engine, @IntRange(from = 0) int level, @NonNull() Texture.PixelBufferDescriptor buffer, @NonNull() @Size(min = 6) Array<int> faceOffsetsInBytes)
setImageis used to specify all six images of a cubemap level andfollows exactly the OpenGL conventionsThis
Textureinstance must useSAMPLER_CUBEMAP.- Parameters:
engine- Engine this texture is associated to.level- Level to set the image for.buffer- Client-side buffer containing the image to set.faceOffsetsInBytes- Offsets in bytes intobufferfor all six images.The offsets are specified in the following order:+x, -x, +y, -y, +z, -z.
-
setExternalImage
void setExternalImage(@NonNull() Engine engine, long eglImage)
Specifies the external image to associate with this
Texture.This
Textureinstance must useSAMPLER_EXTERNAL.Typically the external image is OS specific, and can be a video or camera frame.There are many restrictions when using an external image as a texture, such as:
- only the level of detail (LOD) 0 can be specified
- only NEAREST orLINEAR filtering is supported
- the size and format of the texture is defined by the external image
- Parameters:
engine- Engine this texture is associated to.eglImage- An opaque handle to a platform specific image.
-
setExternalStream
void setExternalStream(@NonNull() Engine engine, @NonNull() Stream stream)
Specifies the external stream to associate with this
Texture.This
Textureinstance must useSAMPLER_EXTERNAL.Typically the external image is OS specific, and can be a video or camera frame.There are many restrictions when using an external image as a texture, such as:
- only the level of detail (LOD) 0 can be specified
- only NEAREST orLINEAR filtering is supported
- the size and format of the texture is defined by the external image
-
generateMipmaps
void generateMipmaps(@NonNull() Engine engine)
Generates all the mipmap levels automatically. This requires the texture to have acolor-renderable format.
This
Textureinstance must not useSAMPLER_CUBEMAP, or it has no effect.- Parameters:
engine- Engine this texture is associated to.
-
generatePrefilterMipmap
void generatePrefilterMipmap(@NonNull() Engine engine, @NonNull() Texture.PixelBufferDescriptor buffer, @NonNull() @Size(min = 6) Array<int> faceOffsetsInBytes, Texture.PrefilterOptions options)
Creates a reflection map from an environment map.
This is a utility function that replaces calls to setImage.The provided environment map is processed and all mipmap levels are populated. Theprocessing is similar to the offline tool
cmgenat a lower quality setting.This function is intended to be used when the environment cannot be processed offline,for instance if it's generated at runtime.
The source data must obey to some constraints:
The current texture must be a cubemap.
The reflections cubemap's internal format cannot be a compressed format.
The reflections cubemap's dimension must be a power-of-two.
This operation is computationally intensive, especially with large environments andis currently synchronous. Expect about 1ms for a 16 × 16 cubemap.
- Parameters:
engine- Engine this texture is associated to.buffer- Client-side buffer containing the image to set.faceOffsetsInBytes- Offsets in bytes intobufferfor all six images.The offsets are specified in the following order:+x, -x, +y, -y, +z, -z.options- Optional parameter to control user-specified quality and options.
-
getNativeObject
long getNativeObject()
-
-
-
-