Skip to content

Commit dfaf0b9

Browse files
committed
Merge branch 'multitexture-gl' into dev
2 parents 2318fec + 4d09b31 commit dfaf0b9

12 files changed

Lines changed: 565 additions & 366 deletions

File tree

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
343343

344344
Please note that Phaser uses a custom build of Pixi and always has done. The following changes have been made to our custom build, not to Pixi in general.
345345

346+
* Multi-Texture support has now been built into our version of Pixi. This can offer dramatic performance increases in WebGL games on GPUs that support multiple texture bindings (which is most of them these days).
347+
* WebGLRenderer.setTexturePriority is the method used to set the priority of textures when the GPU supports multi-texture batching.
348+
* Rope has two new properties `textureIndices` and `textureIndex` to handle multi-texture support.
349+
* Strip has two new properties `textureIndices` and `textureIndex` to handle multi-texture support.
350+
* The following shaders have all been updated to support multi-textures: `ComplexPrimitiveShader`, `PixiFastShader`, `PixiShader`, `PrimitiveShader`, `StripShader`.
351+
* BaseTexture.textureIndex is a new property that controls the index of the texture within the GPU texture cache. Usually you don't change this yourself, and use `renderer.setTexturePriority` instead, but the property is public and available for more advanced use-cases.
346352
* This version contains significant fixes for `DisplayObject.getBounds` and `DisplayObjectContainer.getBounds`. The methods can now accept an optional argument `targetCoordinateSpace` which makes it much more flexible, allowing you to check the bounds against any target, not just local and global ones. If the `targetCoordinateSpace` is a valid DisplayObject:
347353

348354
- If it's a parent of the caller at some level it will return the bounds
@@ -351,8 +357,7 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol
351357
it, and the caller and will calculate the x and y bounds of the caller
352358
relative to the targetCoordinateSpace DisplayObject.
353359

354-
As a result this also fixes how empty Groups are treated when they have no other
355-
children except Groups. So now calculations are correct.
360+
As a result this also fixes how empty Groups are treated when they have no other children except Groups. So now calculations are correct.
356361
* DisplayObjectContainer.contains(child) is a new method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is
357362
used in the new getBounds function.
358363
* Corrected DisplayObjects default `_bounds` rect from (0, 0, 1, 1) to (0, 0, 0, 0).

src/pixi/extras/Rope.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ PIXI.Rope = function(texture, points)
2121
this.uvs = new PIXI.Float32Array(points.length * 4);
2222
this.colors = new PIXI.Float32Array(points.length * 2);
2323
this.indices = new PIXI.Uint16Array(points.length * 2);
24-
24+
this.textureIndices = new PIXI.Float32Array(points.length * 4);
25+
this.textureIndex = texture.baseTexture.textureIndex;
2526

2627
this.refresh();
2728
};
@@ -46,6 +47,8 @@ PIXI.Rope.prototype.refresh = function()
4647
var lastPoint = points[0];
4748
var indices = this.indices;
4849
var colors = this.colors;
50+
var textureIndices = this.textureIndices;
51+
var textureIndex = this.textureIndex;
4952

5053
this.count-=0.2;
5154

@@ -95,6 +98,12 @@ PIXI.Rope.prototype.refresh = function()
9598
indices[index] = index;
9699
indices[index + 1] = index + 1;
97100

101+
textureIndices[index + 0] = textureIndex;
102+
textureIndices[index + 1] = textureIndex;
103+
textureIndices[index + 2] = textureIndex;
104+
textureIndices[index + 3] = textureIndex;
105+
106+
98107
lastPoint = point;
99108
}
100109
};
@@ -168,7 +177,11 @@ PIXI.Rope.prototype.updateTransform = function()
168177
*/
169178
PIXI.Rope.prototype.setTexture = function(texture)
170179
{
180+
console.log(texture);
181+
debugger;
171182
// stop current texture
172183
this.texture = texture;
184+
this.textureIndex = texture.baseTexture.textureIndex;
185+
this.rebindTexture();
173186
//this.updateFrame = true;
174187
};

0 commit comments

Comments
 (0)