mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +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 ()
|
||||
{
|
||||
var gl = this.gl;
|
||||
var vertexBuffer = this.vertexBuffer;
|
||||
var attributes = this.attributes;
|
||||
var program = this.program;
|
||||
var renderer = this.renderer;
|
||||
var vertexSize = this.vertexSize;
|
||||
|
||||
renderer.setProgram(program);
|
||||
renderer.setVertexBuffer(vertexBuffer);
|
||||
renderer.setProgram(this.program);
|
||||
renderer.setVertexBuffer(this.vertexBuffer);
|
||||
|
||||
for (var i = 0; i < attributes.length; i++)
|
||||
{
|
||||
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.setAttribPointers(true);
|
||||
|
||||
this.hasBooted = true;
|
||||
|
||||
|
@ -404,10 +383,14 @@ var WebGLPipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.WebGLPipeline#bind
|
||||
* @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.
|
||||
*/
|
||||
bind: function ()
|
||||
bind: function (reset)
|
||||
{
|
||||
if (reset === undefined) { reset = false; }
|
||||
|
||||
var vertexBuffer = this.vertexBuffer;
|
||||
var program = this.program;
|
||||
var renderer = this.renderer;
|
||||
|
@ -415,7 +398,7 @@ var WebGLPipeline = new Class({
|
|||
renderer.setProgram(program);
|
||||
renderer.setVertexBuffer(vertexBuffer);
|
||||
|
||||
this.setAttribPointers();
|
||||
this.setAttribPointers(reset);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -427,19 +410,40 @@ var WebGLPipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.WebGLPipeline#setAttribPointers
|
||||
* @since 3.50.0
|
||||
*
|
||||
* @param {boolean} [reset=false] - Reset the vertex attribute locations?
|
||||
*
|
||||
* @return {this} This WebGLPipeline instance.
|
||||
*/
|
||||
setAttribPointers: function ()
|
||||
setAttribPointers: function (reset)
|
||||
{
|
||||
if (reset === undefined) { reset = false; }
|
||||
|
||||
var gl = this.gl;
|
||||
var attributes = this.attributes;
|
||||
var vertexSize = this.vertexSize;
|
||||
var program = this.program;
|
||||
|
||||
for (var i = 0; i < attributes.length; 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);
|
||||
}
|
||||
|
|
|
@ -1221,13 +1221,10 @@ var WebGLRenderer = new Class({
|
|||
|
||||
this.setBlendMode(0, true);
|
||||
|
||||
this.resetTextures(true);
|
||||
|
||||
this.currentActiveTexture = 1;
|
||||
this.startActiveTexture++;
|
||||
this.resetTextures();
|
||||
|
||||
this.currentPipeline = pipelineInstance;
|
||||
this.currentPipeline.bind();
|
||||
this.currentPipeline.bind(true);
|
||||
this.currentPipeline.onBind();
|
||||
},
|
||||
|
||||
|
|
|
@ -110,11 +110,15 @@ var BitmapMaskPipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#bind
|
||||
* @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.
|
||||
*/
|
||||
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 program = this.program;
|
||||
|
|
|
@ -149,11 +149,15 @@ var LightPipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#bind
|
||||
* @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.
|
||||
*/
|
||||
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 program = this.program;
|
||||
|
|
|
@ -298,11 +298,15 @@ var MultiPipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#bind
|
||||
* @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.
|
||||
*/
|
||||
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);
|
||||
|
||||
|
|
|
@ -308,11 +308,15 @@ var SinglePipeline = new Class({
|
|||
* @method Phaser.Renderer.WebGL.Pipelines.SinglePipeline#bind
|
||||
* @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.
|
||||
*/
|
||||
bind: function ()
|
||||
bind: function (reset)
|
||||
{
|
||||
WebGLPipeline.prototype.bind.call(this);
|
||||
if (reset === undefined) { reset = false; }
|
||||
|
||||
WebGLPipeline.prototype.bind.call(this, reset);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue