mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
StaticTilemapLayer.upload
will now set the vertex attributes and buffer the data, and handles internal checks more efficiently.
This commit is contained in:
parent
6e15f6b77d
commit
10c19bd24d
1 changed files with 130 additions and 115 deletions
|
@ -436,7 +436,12 @@ var StaticTilemapLayer = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Upload the tile data to a VBO.
|
||||
* If the given tileset is dirty, or hasn't been rendered before, this will create a new
|
||||
* ArrayBuffer object and iterate through all of the tiles, generating batch data for
|
||||
* each one, storing the final results into a STATIC vertex buffer.
|
||||
*
|
||||
* If the tileset isn't dirty, this method simply returns after setting the vertex buffer
|
||||
* and buffering the data.
|
||||
*
|
||||
* @method Phaser.Tilemaps.StaticTilemapLayer#upload
|
||||
* @since 3.0.0
|
||||
|
@ -448,28 +453,39 @@ var StaticTilemapLayer = new Class({
|
|||
*/
|
||||
upload: function (camera, tilesetIndex)
|
||||
{
|
||||
var pipeline = this.pipeline;
|
||||
|
||||
var renderer = this.renderer;
|
||||
|
||||
var gl = renderer.gl;
|
||||
|
||||
var pipeline = renderer.pipelines.TextureTintPipeline;
|
||||
var vertexBuffer = this.vertexBuffer[tilesetIndex];
|
||||
var bufferData = this.bufferData[tilesetIndex];
|
||||
|
||||
if (this.dirty[tilesetIndex])
|
||||
if (!this.dirty[tilesetIndex] && vertexBuffer)
|
||||
{
|
||||
renderer.setVertexBuffer(vertexBuffer);
|
||||
|
||||
pipeline.setAttribPointers();
|
||||
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
var layer = this.layer;
|
||||
var tileset = this.tileset[tilesetIndex];
|
||||
var mapWidth = this.layer.width;
|
||||
var mapHeight = this.layer.height;
|
||||
var mapWidth = layer.width;
|
||||
var mapHeight = layer.height;
|
||||
var width = tileset.image.source[0].width;
|
||||
var height = tileset.image.source[0].height;
|
||||
var mapData = this.layer.data;
|
||||
var mapData = layer.data;
|
||||
var tile;
|
||||
var row;
|
||||
var col;
|
||||
var renderOrder = this._renderOrder;
|
||||
var minTileIndex = tileset.firstgid;
|
||||
var maxTileIndex = tileset.firstgid + tileset.total;
|
||||
|
||||
var vertexBuffer = this.vertexBuffer[tilesetIndex];
|
||||
var bufferData = this.bufferData[tilesetIndex];
|
||||
var vOffset = -1;
|
||||
var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6;
|
||||
|
||||
|
@ -570,13 +586,12 @@ var StaticTilemapLayer = new Class({
|
|||
|
||||
this.vertexBuffer[tilesetIndex] = vertexBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
renderer.setVertexBuffer(vertexBuffer);
|
||||
|
||||
pipeline.setAttribPointers();
|
||||
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue