mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Use DrawingContext dimensions for uniform setting.
Specifically `uResolution` and `uProjectionMatrix`. This allows the context to control rendering more accurately.
This commit is contained in:
parent
7ce2d46d7c
commit
d6bba864a2
5 changed files with 50 additions and 22 deletions
|
@ -165,6 +165,24 @@ var DrawingContext = new Class({
|
|||
*/
|
||||
this.inUse = false;
|
||||
|
||||
/**
|
||||
* The width of the framebuffer.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.DrawingContext#width
|
||||
* @type {number}
|
||||
* @since 3.90.0
|
||||
*/
|
||||
this.width = 0;
|
||||
|
||||
/**
|
||||
* The height of the framebuffer.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.DrawingContext#height
|
||||
* @type {number}
|
||||
* @since 3.90.0
|
||||
*/
|
||||
this.height = 0;
|
||||
|
||||
if (options.autoResize)
|
||||
{
|
||||
this.renderer.on(Events.RESIZE, this.resize, this);
|
||||
|
@ -254,6 +272,8 @@ var DrawingContext = new Class({
|
|||
this.texture = source.texture;
|
||||
this.camera = source.camera;
|
||||
this.blendMode = source.blendMode;
|
||||
this.width = source.width;
|
||||
this.height = source.height;
|
||||
|
||||
this.state = {
|
||||
bindings:
|
||||
|
|
|
@ -109,20 +109,6 @@ var BatchHandlerQuad = new Class({
|
|||
return buffer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set new dimensions for the renderer. This is called automatically when the renderer is resized.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.BatchTexturedTintedTransformedQuads#resize
|
||||
* @since 3.90.0
|
||||
* @param {number} width - The new width of the renderer.
|
||||
* @param {number} height - The new height of the renderer.
|
||||
*/
|
||||
resize: function (width, height)
|
||||
{
|
||||
this.program.setUniform('uResolution', [ width, height ]);
|
||||
this.program.setUniform('uProjectionMatrix', this.manager.renderer.projectionMatrix.val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the number of draw calls per batch.
|
||||
* This rebuilds the shader program with the new draw call count.
|
||||
|
@ -196,6 +182,20 @@ var BatchHandlerQuad = new Class({
|
|||
'uRoundPixels',
|
||||
drawingContext.camera.roundPixels
|
||||
);
|
||||
|
||||
this.program.setUniform(
|
||||
'uResolution',
|
||||
[ drawingContext.width, drawingContext.height ]
|
||||
);
|
||||
|
||||
drawingContext.renderer.setProjectionMatrix(
|
||||
drawingContext.width,
|
||||
drawingContext.height
|
||||
);
|
||||
this.program.setUniform(
|
||||
'uProjectionMatrix',
|
||||
drawingContext.renderer.projectionMatrix.val
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -149,10 +149,8 @@ var BatchHandlerQuadLight = new Class({
|
|||
var vec = this._lightVector;
|
||||
var height = this.manager.renderer.height;
|
||||
|
||||
program.setUniform(
|
||||
'uRoundPixels',
|
||||
drawingContext.camera.roundPixels
|
||||
);
|
||||
BatchHandlerQuad.prototype.onRunBegin.call(this, drawingContext);
|
||||
|
||||
program.setUniform(
|
||||
'uCamera',
|
||||
[
|
||||
|
|
|
@ -90,14 +90,22 @@ var BatchHandlerTriFlat = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set new dimensions for the renderer. This is called automatically when the renderer is resized.
|
||||
* Called at the beginning of the `run` method.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.BatchHandlerTriFlat#resize
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.BatchHandlerTriFlat#onRunBegin
|
||||
* @since 3.90.0
|
||||
* @param {Phaser.Types.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context.
|
||||
*/
|
||||
resize: function ()
|
||||
onRunBegin: function (drawingContext)
|
||||
{
|
||||
this.program.setUniform('uProjectionMatrix', this.manager.renderer.projectionMatrix.val);
|
||||
drawingContext.renderer.setProjectionMatrix(
|
||||
drawingContext.width,
|
||||
drawingContext.height
|
||||
);
|
||||
this.program.setUniform(
|
||||
'uProjectionMatrix',
|
||||
drawingContext.renderer.projectionMatrix.val
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -148,6 +148,8 @@ var BatchHandlerTriFlatLight = new Class({
|
|||
var vec = this._lightVector;
|
||||
var height = this.manager.renderer.height;
|
||||
|
||||
BatchHandlerTriFlat.prototype.onRunBegin.call(this, drawingContext);
|
||||
|
||||
program.setUniform(
|
||||
'uCamera',
|
||||
[
|
||||
|
|
Loading…
Add table
Reference in a new issue