Package com.google.android.filament
Class Texture.Builder
- java.lang.Object
-
- com.google.android.filament.Texture.Builder
-
- Enclosing class:
- Texture
public static class Texture.Builder extends java.lang.ObjectUseBuilderto construct aTextureobject instance.
-
-
Constructor Summary
Constructors Constructor Description Builder()UseBuilderto construct aTextureobject instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Texturebuild(Engine engine)Creates a newTextureinstance.Texture.Builderdepth(int depth)Specifies the texture's number of layers.Texture.Builderformat(Texture.InternalFormat format)Specifies the texture's internal format.Texture.Builderheight(int height)Specifies the height of the texture in texels.Texture.BuilderimportTexture(long id)Specify a native texture to import as a Filament texture.Texture.Builderlevels(int levels)Specifies the number of mipmap levelsTexture.Buildersampler(Texture.Sampler target)Specifies the type of sampler to use.Texture.Builderswizzle(Texture.Swizzle r, Texture.Swizzle g, Texture.Swizzle b, Texture.Swizzle a)Specifies how a texture's channels map to color componentsTexture.Builderusage(int flags)Sets the usage flags, which is necessary when attaching toRenderTarget.Texture.Builderwidth(int width)Specifies the width of the texture in texels.
-
-
-
Method Detail
-
width
@NonNull public Texture.Builder width(@IntRange(from=1L) int width)
Specifies the width of the texture in texels.- Parameters:
width- texture width in texels, must be at least 1. Default is 1.- Returns:
- This Builder, for chaining calls.
-
height
@NonNull public Texture.Builder height(@IntRange(from=1L) int height)
Specifies the height of the texture in texels.- Parameters:
height- texture height in texels, must be at least 1. Default is 1.- Returns:
- This Builder, for chaining calls.
-
depth
@NonNull public Texture.Builder depth(@IntRange(from=1L) int depth)
Specifies the texture's number of layers. Values greater than 1 create a 3D texture.This
Textureinstance must useSAMPLER_2D_ARRAYor it has no effect.- Parameters:
depth- texture number of layers. Default is 1.- Returns:
- This Builder, for chaining calls.
-
levels
@NonNull public Texture.Builder levels(@IntRange(from=1L) int levels)
Specifies the number of mipmap levels- Parameters:
levels- must be at least 1 and less or equal tofloor(log2(max(width, height))) + 1. Default is 1.- Returns:
- This Builder, for chaining calls.
-
sampler
@NonNull public Texture.Builder sampler(@NonNull Texture.Sampler target)
Specifies the type of sampler to use.- Parameters:
target-Samplertype- Returns:
- This Builder, for chaining calls.
-
format
@NonNull public Texture.Builder format(@NonNull Texture.InternalFormat format)
Specifies the texture's internal format.The internal format specifies how texels are stored (which may be different from how they're specified in
Texture.setImage(com.google.android.filament.Engine, int, com.google.android.filament.Texture.PixelBufferDescriptor)).InternalFormatspecifies both the color components and the data type used.- Parameters:
format- texture'sinternal format.- Returns:
- This Builder, for chaining calls.
-
usage
@NonNull public Texture.Builder usage(int flags)
Sets the usage flags, which is necessary when attaching toRenderTarget. The flags argument much be a combination ofTexture.Usageflags.
-
swizzle
@NonNull public Texture.Builder swizzle(@NonNull Texture.Swizzle r, @NonNull Texture.Swizzle g, @NonNull Texture.Swizzle b, @NonNull Texture.Swizzle a)
Specifies how a texture's channels map to color components- Parameters:
r- texture channel for red componentg- texture channel for green componentb- texture channel for blue componenta- texture channel for alpha component- Returns:
- This Builder, for chaining calls.
-
importTexture
@NonNull public Texture.Builder importTexture(long id)
Specify a native texture to import as a Filament texture.The texture id is backend-specific:
- OpenGL: GLuint texture ID
- Parameters:
id- a backend specific texture identifier- Returns:
- This Builder, for chaining calls.
-
build
@NonNull public Texture build(@NonNull Engine engine)
Creates a newTextureinstance.- Parameters:
engine- TheEngineto associate thisTexturewith.- Returns:
- A newly created
Texture - Throws:
java.lang.IllegalStateException- if a parameter to a builder function was invalid. A mode detailed message about the error is output in the system log.
-
-