PIXI.RenderTexture

class RenderTexture extends PIXI.Texture

A RenderTexture 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 RenderTexture should be preloaded otherwise black rectangles will be drawn instead.

Hint-2: The actual memory allocation will happen on first render. You shouldn't create renderTextures each frame just to delete them after, try to reuse them.

A RenderTexture takes a snapshot of any Display Object given to its render method. For example:

let renderer = PIXI.autoDetectRenderer();
let renderTexture = PIXI.RenderTexture.create({ width: 800, height: 600 });
let sprite = PIXI.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});

Note that you should not create a new renderer, but reuse the same one as the rest of the application.

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()

let renderTexture = new PIXI.RenderTexture.create({ width: 100, height: 100 });

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

Constructor


new PIXI.RenderTexture(baseRenderTexture: PIXI.BaseRenderTexture, frame: PIXI.Rectangle) → {}
Parameters:
Name Type Attributes Description
baseRenderTexture PIXI.BaseRenderTexture

The base texture object that this texture uses.

frame PIXI.Rectangle

<optional>

The rectangle frame of the texture to show.

Summary


Properties from RenderTexture

PIXI.Rectangle | null
filterFrame

Stores sourceFrame when this texture is inside current filter stack.

string | number | null
filterPoolKey
PIXI.Framebuffer
framebuffer
PIXI.MSAA_QUALITY
multisample = PIXI.MSAA_QUALITY.NONE

Properties inherited from Texture

PIXI.Rectangle
_frame
PIXI.BaseTexture<R>
baseTexture

The base texture that this texture uses.

PIXI.Point
defaultAnchor = {0,0}
PIXI.Rectangle
frame
number
height

The height of the Texture in pixels.

boolean
noFrame

Does this Texture have any frame data assigned to it?

PIXI.Rectangle
orig

This is the area of original texture, before it was put in atlas.

number
resolution
number
rotate
Array<string>
textureCacheIds
PIXI.Rectangle
trim
PIXI.TextureMatrix
uvMatrix

Default TextureMatrix instance for this texture. By default, that object is not created because its heavy.

boolean
valid

This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.

number
width

The width of the Texture in pixels.

number
protected _updateID
PIXI.TextureUvs
protected _uvs

Methods inherited from Texture

PIXI.BaseTexture
castToBaseTexture()

Utility function for BaseTexture|Texture cast.

PIXI.Texture
clone()
void
destroy(destroyBase: boolean)
void
update()

Updates this texture on the gpu.

void
updateUvs()
void
protected onBaseTextureUpdated(baseTexture: PIXI.BaseTexture)

Public Properties


filterFrame RenderTexture.ts:52
filterFrame: PIXI.Rectangle | null

Stores sourceFrame when this texture is inside current filter stack.

You can read it inside filters.

filterPoolKey RenderTexture.ts:60
filterPoolKey: string | number | null

The key for pooled texture of FilterSystem.

See: PIXI.RenderTexturePool
framebuffer RenderTexture.ts:82
framebuffer: PIXI.Framebuffer

Shortcut to this.baseTexture.framebuffer, saves baseTexture cast.

multisample RenderTexture.ts:91
multisample: PIXI.MSAA_QUALITY = PIXI.MSAA_QUALITY.NONE

Shortcut to this.framebuffer.multisample.

Public Methods


create RenderTexture.ts:148
static create(width: number, height: number, scaleMode: PIXI.SCALE_MODES, resolution: number) → {PIXI.RenderTexture}
Deprecated: since 6.0.0

Use the object-based construction instead.

Parameters:
Name Type Attributes Default Description
width number

<optional>

height number

<optional>

scaleMode PIXI.SCALE_MODES

<optional>

PIXI.settings.SCALE_MODE
resolution number

<optional>

PIXI.settings.FILTER_RESOLUTION
Returns:
Type Description
PIXI.RenderTexture
create RenderTexture.ts:158
static create(options: IBaseTextureOptions) → {PIXI.RenderTexture}

A short hand way of creating a render texture.

Parameters:
Name Type Attributes Default Description
options IBaseTextureOptions

<optional>

Options

options.width number

<optional>

100

The width of the render texture

options.height number

<optional>

100

The height of the render texture

options.scaleMode PIXI.SCALE_MODES

<optional>

PIXI.settings.SCALE_MODE

See PIXI.SCALE_MODES for possible values

options.resolution number

<optional>

PIXI.settings.RESOLUTION

The resolution / device pixel ratio of the texture being generated

options.multisample PIXI.MSAA_QUALITY

<optional>

PIXI.MSAA_QUALITY.NONE

The number of samples of the frame buffer

Returns:
Type Description
PIXI.RenderTexture

The new render texture

resize RenderTexture.ts:105
resize(desiredWidth: number, desiredHeight: number, resizeBaseTexture: boolean) → {void}

Resizes the RenderTexture.

Parameters:
Name Type Default Description
desiredWidth number

The desired width to resize to.

desiredHeight number

The desired height to resize to.

resizeBaseTexture boolean true

Should the baseTexture.width and height values be resized as well?

Returns:
Type Description
void
setResolution RenderTexture.ts:131
setResolution(resolution: number) → {void}

Changes the resolution of baseTexture, but does not change framebuffer size.

Parameters:
Name Type Description
resolution number

The new resolution to apply to RenderTexture

Returns:
Type Description
void

Powered by webdoc!