mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
Added reset
property to Bind to get new vertex attrib locations
This commit is contained in:
parent
e4ec0bd182
commit
ca99c4564f
6 changed files with 58 additions and 41 deletions
|
@ -277,33 +277,12 @@ var WebGLPipeline = new Class({
|
||||||
*/
|
*/
|
||||||
boot: function ()
|
boot: function ()
|
||||||
{
|
{
|
||||||
var gl = this.gl;
|
|
||||||
var vertexBuffer = this.vertexBuffer;
|
|
||||||
var attributes = this.attributes;
|
|
||||||
var program = this.program;
|
|
||||||
var renderer = this.renderer;
|
var renderer = this.renderer;
|
||||||
var vertexSize = this.vertexSize;
|
|
||||||
|
|
||||||
renderer.setProgram(program);
|
renderer.setProgram(this.program);
|
||||||
renderer.setVertexBuffer(vertexBuffer);
|
renderer.setVertexBuffer(this.vertexBuffer);
|
||||||
|
|
||||||
for (var i = 0; i < attributes.length; i++)
|
this.setAttribPointers(true);
|
||||||
{
|
|
||||||
var element = attributes[i];
|
|
||||||
var location = gl.getAttribLocation(program, element.name);
|
|
||||||
|
|
||||||
if (location >= 0)
|
|
||||||
{
|
|
||||||
gl.enableVertexAttribArray(location);
|
|
||||||
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset);
|
|
||||||
element.enabled = true;
|
|
||||||
element.location = location;
|
|
||||||
}
|
|
||||||
else if (location !== -1)
|
|
||||||
{
|
|
||||||
gl.disableVertexAttribArray(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hasBooted = true;
|
this.hasBooted = true;
|
||||||
|
|
||||||
|
@ -404,10 +383,14 @@ var WebGLPipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.WebGLPipeline#bind
|
* @method Phaser.Renderer.WebGL.WebGLPipeline#bind
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
bind: function ()
|
bind: function (reset)
|
||||||
{
|
{
|
||||||
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
var vertexBuffer = this.vertexBuffer;
|
var vertexBuffer = this.vertexBuffer;
|
||||||
var program = this.program;
|
var program = this.program;
|
||||||
var renderer = this.renderer;
|
var renderer = this.renderer;
|
||||||
|
@ -415,7 +398,7 @@ var WebGLPipeline = new Class({
|
||||||
renderer.setProgram(program);
|
renderer.setProgram(program);
|
||||||
renderer.setVertexBuffer(vertexBuffer);
|
renderer.setVertexBuffer(vertexBuffer);
|
||||||
|
|
||||||
this.setAttribPointers();
|
this.setAttribPointers(reset);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -427,19 +410,40 @@ var WebGLPipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.WebGLPipeline#setAttribPointers
|
* @method Phaser.Renderer.WebGL.WebGLPipeline#setAttribPointers
|
||||||
* @since 3.50.0
|
* @since 3.50.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Reset the vertex attribute locations?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
setAttribPointers: function ()
|
setAttribPointers: function (reset)
|
||||||
{
|
{
|
||||||
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
var gl = this.gl;
|
var gl = this.gl;
|
||||||
var attributes = this.attributes;
|
var attributes = this.attributes;
|
||||||
var vertexSize = this.vertexSize;
|
var vertexSize = this.vertexSize;
|
||||||
|
var program = this.program;
|
||||||
|
|
||||||
for (var i = 0; i < attributes.length; i++)
|
for (var i = 0; i < attributes.length; i++)
|
||||||
{
|
{
|
||||||
var element = attributes[i];
|
var element = attributes[i];
|
||||||
|
|
||||||
if (element.enabled)
|
if (reset)
|
||||||
|
{
|
||||||
|
var location = gl.getAttribLocation(program, element.name);
|
||||||
|
|
||||||
|
if (location >= 0)
|
||||||
|
{
|
||||||
|
gl.enableVertexAttribArray(location);
|
||||||
|
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset);
|
||||||
|
element.enabled = true;
|
||||||
|
element.location = location;
|
||||||
|
}
|
||||||
|
else if (location !== -1)
|
||||||
|
{
|
||||||
|
gl.disableVertexAttribArray(location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (element.enabled)
|
||||||
{
|
{
|
||||||
gl.vertexAttribPointer(element.location, element.size, element.type, element.normalized, vertexSize, element.offset);
|
gl.vertexAttribPointer(element.location, element.size, element.type, element.normalized, vertexSize, element.offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1221,13 +1221,10 @@ var WebGLRenderer = new Class({
|
||||||
|
|
||||||
this.setBlendMode(0, true);
|
this.setBlendMode(0, true);
|
||||||
|
|
||||||
this.resetTextures(true);
|
this.resetTextures();
|
||||||
|
|
||||||
this.currentActiveTexture = 1;
|
|
||||||
this.startActiveTexture++;
|
|
||||||
|
|
||||||
this.currentPipeline = pipelineInstance;
|
this.currentPipeline = pipelineInstance;
|
||||||
this.currentPipeline.bind();
|
this.currentPipeline.bind(true);
|
||||||
this.currentPipeline.onBind();
|
this.currentPipeline.onBind();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -110,11 +110,15 @@ var BitmapMaskPipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#bind
|
* @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#bind
|
||||||
* @since 3.50.0
|
* @since 3.50.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
bind: function ()
|
bind: function (reset)
|
||||||
{
|
{
|
||||||
WebGLPipeline.prototype.bind.call(this);
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
|
WebGLPipeline.prototype.bind.call(this, reset);
|
||||||
|
|
||||||
var renderer = this.renderer;
|
var renderer = this.renderer;
|
||||||
var program = this.program;
|
var program = this.program;
|
||||||
|
|
|
@ -149,11 +149,15 @@ var LightPipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#bind
|
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#bind
|
||||||
* @since 3.50.0
|
* @since 3.50.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
bind: function ()
|
bind: function (reset)
|
||||||
{
|
{
|
||||||
WebGLPipeline.prototype.bind.call(this);
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
|
WebGLPipeline.prototype.bind.call(this, reset);
|
||||||
|
|
||||||
var renderer = this.renderer;
|
var renderer = this.renderer;
|
||||||
var program = this.program;
|
var program = this.program;
|
||||||
|
|
|
@ -298,11 +298,15 @@ var MultiPipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#bind
|
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#bind
|
||||||
* @since 3.50.0
|
* @since 3.50.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
bind: function ()
|
bind: function (reset)
|
||||||
{
|
{
|
||||||
WebGLPipeline.prototype.bind.call(this);
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
|
WebGLPipeline.prototype.bind.call(this, reset);
|
||||||
|
|
||||||
this.renderer.setInt1iv(this.program, 'uMainSampler', this.renderer.textureIndexes);
|
this.renderer.setInt1iv(this.program, 'uMainSampler', this.renderer.textureIndexes);
|
||||||
|
|
||||||
|
|
|
@ -308,11 +308,15 @@ var SinglePipeline = new Class({
|
||||||
* @method Phaser.Renderer.WebGL.Pipelines.SinglePipeline#bind
|
* @method Phaser.Renderer.WebGL.Pipelines.SinglePipeline#bind
|
||||||
* @since 3.50.0
|
* @since 3.50.0
|
||||||
*
|
*
|
||||||
|
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
|
||||||
|
*
|
||||||
* @return {this} This WebGLPipeline instance.
|
* @return {this} This WebGLPipeline instance.
|
||||||
*/
|
*/
|
||||||
bind: function ()
|
bind: function (reset)
|
||||||
{
|
{
|
||||||
WebGLPipeline.prototype.bind.call(this);
|
if (reset === undefined) { reset = false; }
|
||||||
|
|
||||||
|
WebGLPipeline.prototype.bind.call(this, reset);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue