This will hook onto the renderer's contextChange
and prerender signals.
The renderer this works for.
Protected_Pool of ViewableBuffer objects that are sorted in
order of increasing size. The flush method uses
the buffer with the least size above the amount
it requires. These are used for passing attributes.
The first buffer has a size of 8; each subsequent buffer has double capacity of its previous.
Protected_Protected_Protected_Buffer of objects that are yet to be rendered.
Protected_Data for texture batch builder, helps to save a bit of CPU on a pass.
Protected_Number of elements that are buffered and are waiting to be flushed.
Protected_Protected_A flush may occur multiple times in a single
frame. On iOS devices or when
BatchRenderer.canUploadSameBuffer is false, the
batch renderer does not upload data to the same
WebGLBuffer for performance reasons.
This is the index into packedGeometries that points to
geometry holding the most recent buffers.
Protected_Pool of Uint16Array objects that are sorted in
order of increasing size. The flush method uses
the buffer with the least size above the amount
it requires. These are used for passing indices.
The first buffer has a size of 12; each subsequent buffer has double capacity of its previous.
Protected_Protected_Protected_Total count of all indices used by the currently buffered objects.
Protected_This shader is generated by this.shaderGenerator.
It is generated specifically to handle the required number of textures being batched together.
Protected_Protected_Total count of all vertices used by the currently buffered objects.
ProtectedgeometryThe class that represents the geometry of objects that are going to be batched with this.
ReadonlymaxMaximum number of textures that can be uploaded to
the GPU under the current context. It is initialized
properly in this.contextChange.
ProtectedrendererThe renderer this manager works for.
ProtectedshaderThis is used to generate a shader that can
color each vertex based on a aTextureId
attribute that points to an texture in uSampler.
This enables the objects with different textures to be drawn in the same draw call.
You can customize your shader by creating your custom shader generator.
The number of bufferable objects before a flush occurs automatically.
ReadonlystateThe WebGL state in which this renderer will work.
ProtectedvertexSize of data being buffered per vertex in the attribute buffers (in floats). By default, the batch-renderer plugin uses 6:
| aVertexPosition | 2 |
|---|---|
| aTextureCoords | 2 |
| aColor | 1 |
| aTextureId | 1 |
Static_Pool of BatchDrawCall objects that flush used
to create "batches" of the objects being rendered.
These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.
Static_Pool of BatchDrawCall objects that flush used
to create "batches" of the objects being rendered.
These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.
StaticdefaultThe default sprite batch size.
The default aims to balance desktop and mobile devices.
StaticcanStaticdefaultThe default fragment shader source
StaticdefaultStaticdefaultThe default vertex shader source
Populating drawcalls for rendering
Handles the contextChange signal.
It calculates this.maxTextures and allocating the packed-geometry object pool.
Destroys this BatchRenderer. It cannot be used again.
Renders the content now and empties the current batch.
Fetches an attribute buffer from this._aBuffers that can hold atleast size floats.
minimum capacity required
size floatsFetches an index buffer from this._iBuffers that can
have at least size capacity.
minimum required capacity
size indices.Makes sure that static and dynamic flush pooled objects have correct dimensions.
Handles the prerender signal. It ensures that flushes start from the first geometry object again.
Takes the four batching parameters of element, interleaves
and pushes them into the batching attribute/index buffers given.
It uses these properties: vertexData uvs, textureId and
indicies. It also uses the "tint" of the base-texture, if
present.
element being rendered
attribute buffer.
index buffer
number of floats already in the attribute buffer
number of indices already in indexBuffer
Buffers the "batchable" object. It need not be rendered immediately.
the element to render when using this renderer
Set the shader generator.
Optionaloptions: { fragment?: string; vertex?: string }Optionalfragment?: stringFragment shader template
Optionalvertex?: stringVertex shader source
Starts a new sprite batch.
Stops and flushes the current batch.
Renderer dedicated to drawing and batching sprites.
This is the default batch renderer. It buffers objects with texture-based geometries and renders them in batches. It uploads multiple textures to the GPU to reduce to the number of draw calls.
Memberof
PIXI