Class BaseRenderTexture

A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.

Hint: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded otherwise black rectangles will be drawn instead.

A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:

import { autoDetectRenderer, BaseRenderTexture, RenderTexture, Sprite } from 'pixi.js';

const renderer = autoDetectRenderer();
const baseRenderTexture = new BaseRenderTexture({ width: 800, height: 600 });
const renderTexture = new RenderTexture(baseRenderTexture);
const sprite = Sprite.from('spinObj_01.png');

sprite.position.x = 800 / 2;
sprite.position.y = 600 / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;

renderer.render(sprite, { renderTexture });

// The Sprite in this case will be rendered using its local transform.
// To render this sprite at 0,0 you can clear the transform
sprite.setTransform();

const baseRenderTexture = new BaseRenderTexture({ width: 100, height: 100 });
const renderTexture = new RenderTexture(baseRenderTexture);

renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture

PIXI

Hierarchy (View Summary)

Constructors

Properties

_batchEnabled: number

Number of the texture batch, used by multi-texture renderers

_batchLocation: number

Location inside texture batch, used by multi-texture renderers

_clear: Color
alphaMode: ALPHA_MODES

How to treat premultiplied alpha, see PIXI.ALPHA_MODES.

PIXI.ALPHA_MODES.UNPACK
anisotropicLevel: number

Anisotropic filtering level of texture

0
cacheId: string

Currently default cache ID.

destroyed: boolean

Flag if BaseTexture has been destroyed.

dirtyId: number

Used by TextureSystem to only update texture to the GPU when needed. Please call update() to increment it.

filterStack: any[]

The data structure for the filters.

format: FORMATS

The pixel format of the texture

PIXI.FORMATS.RGBA
framebuffer: Framebuffer

The framebuffer of this base texture.

height: number

The height of the base texture set when the image has loaded

isPowerOfTwo: boolean

Whether or not the texture is a power of two, try to use power of two textures as much as you can

false
ktxKeyValueData: Map<string, DataView>
maskStack: MaskData[]

The data structure for the stencil masks.

Whether its a part of another texture, handled by ArrayResource or CubeResource

resolution: number

The resolution / device pixel ratio of the texture

PIXI.settings.RESOLUTION
resource: Resource

The resource used by this BaseTexture, there can only be one resource per BaseTexture, but textures can share resources.

target: TARGETS

The target type

PIXI.TARGETS.TEXTURE_2D
textureCacheIds: string[]

The collection of alternative cache ids, since some BaseTextures can have more than one ID, short name and longer full URL

type: TYPES

The type of resource data

PIXI.TYPES.UNSIGNED_BYTE
valid: boolean

Generally speaking means when resource is loaded.

width: number

The width of the base texture set when the image has loaded

_globalBatch: number

Global number of the texture batch, used by multi-texture renderers.

defaultOptions: IBaseTextureOptions<any>

Default options used when creating BaseTexture objects.

PIXI.BaseTexture

prefixed: string | boolean

Accessors

  • get clear(): Color
  • Color object when clearning the texture.

    Returns Color

    7.2.0

  • get clearColor(): ColorSource
  • Returns ColorSource

  • set clearColor(value: ColorSource): void
  • Color when clearning the texture.

    Parameters

    Returns void

  • get mipmap(): MIPMAP_MODES
  • Mipmap mode of the texture, affects downscaled images

    Returns MIPMAP_MODES

    PIXI.MIPMAP_MODES.POW2
    
  • set mipmap(value: MIPMAP_MODES): void
  • Parameters

    Returns void

  • get multisample(): MSAA_QUALITY
  • Shortcut to this.framebuffer.multisample.

    Returns MSAA_QUALITY

    PIXI.MSAA_QUALITY.NONE
    
  • set multisample(value: MSAA_QUALITY): void
  • Parameters

    Returns void

  • get realHeight(): number
  • Pixel height of the source of this texture

    Returns number

  • get realWidth(): number
  • Pixel width of the source of this texture

    Returns number

  • get scaleMode(): SCALE_MODES
  • The scale mode to apply when scaling this texture

    Returns SCALE_MODES

    PIXI.SCALE_MODES.LINEAR
    
  • set scaleMode(value: SCALE_MODES): void
  • Parameters

    Returns void

  • get wrapMode(): WRAP_MODES
  • How the texture wraps

    Returns WRAP_MODES

    PIXI.WRAP_MODES.CLAMP
    
  • set wrapMode(value: WRAP_MODES): void
  • Parameters

    Returns void

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Destroys this texture.

    Returns void

  • Frees the texture and framebuffer from WebGL memory without destroying this texture object. This means you can still use the texture later which will upload it to GPU memory again.

    Returns void

    PIXI.BaseTexture#dispose

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns (...args: any[]) => void[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optionalfn: (...args: any[]) => void
    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optionalevent: string | symbol

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optionalfn: (...args: any[]) => void
    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Resizes the BaseRenderTexture.

    Parameters

    • desiredWidth: number

      The desired width to resize to.

    • desiredHeight: number

      The desired height to resize to.

    Returns void

  • Sets real size of baseTexture, preserves current resolution.

    Parameters

    • realWidth: number

      Full rendered width

    • realHeight: number

      Full rendered height

    • Optionalresolution: number

      Optionally set resolution

    Returns this

    • this
  • Changes resolution

    Parameters

    • resolution: number

      res

    Returns this

    • this
  • Sets the resource if it wasn't set. Throws error if resource already present

    Parameters

    • resource: Resource

      that is managing this BaseTexture

    Returns this

    • this
  • Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.

    Parameters

    • desiredWidth: number

      Desired visual width

    • desiredHeight: number

      Desired visual height

    • Optionalresolution: number

      Optionally set resolution

    Returns this

    • this
  • Invalidates the object. Texture becomes valid if width and height are greater than zero.

    Returns void

  • Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.

    Parameters

    Returns void