Class Texture.Builder

  • Enclosing class:
    Texture

    public static class Texture.Builder
    extends java.lang.Object
    Use Builder to construct a Texture object instance.
    • Constructor Detail

      • Builder

        public Builder()
        Use Builder to construct a Texture object instance.
    • 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 Texture instance must use SAMPLER_2D_ARRAY or 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 to floor(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 - Sampler type
        Returns:
        This Builder, for chaining calls.
      • usage

        @NonNull
        public Texture.Builder usage​(int flags)
        Sets the usage flags, which is necessary when attaching to RenderTarget. The flags argument much be a combination of Texture.Usage flags.
      • 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 component
        g - texture channel for green component
        b - texture channel for blue component
        a - 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 new Texture instance.
        Parameters:
        engine - The Engine to associate this Texture with.
        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.