From 4ac4d406b248479e0fcbea1b7dcf7cef8da50b3a Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 19 Jan 2017 23:20:36 +0000 Subject: [PATCH] Hooked up SpriteBatch. --- v3/src/boot/Game.js | 2 +- v3/src/checksum.js | 2 +- .../gameobjects/image/ImageWebGLRenderer.js | 20 ++++++++++++++----- v3/src/renderer/webgl/WebGLRenderer.js | 15 ++++++++++++++ v3/src/textures/TextureManager.js | 5 +++-- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/v3/src/boot/Game.js b/v3/src/boot/Game.js index 8b2abc8cf..90d19d1ed 100644 --- a/v3/src/boot/Game.js +++ b/v3/src/boot/Game.js @@ -37,7 +37,7 @@ var Game = function (config) /** * @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager. */ - this.textures = new TextureManager(); + this.textures = new TextureManager(this); /** * @property {Phaser.Cache} cache - Reference to the assets cache. diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 49df6b42c..3c44bccf8 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '98f0c510-de98-11e6-aa23-b3f509f20724' +build: '8e926790-de9d-11e6-bab6-b1cd883c1600' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/gameobjects/image/ImageWebGLRenderer.js b/v3/src/gameobjects/image/ImageWebGLRenderer.js index 63b4ca2b3..4914bcde9 100644 --- a/v3/src/gameobjects/image/ImageWebGLRenderer.js +++ b/v3/src/gameobjects/image/ImageWebGLRenderer.js @@ -11,12 +11,22 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage) return; } - var verts = src.transform.getVertexData(interpolationPercentage, renderer); - var index = src.frame.source.glTextureIndex; - var tint = src.color._glTint; - var bg = src.color._glBg; + // var verts = src.transform.getVertexData(interpolationPercentage, renderer); + // var index = src.frame.source.glTextureIndex; + // var tint = src.color._glTint; + // var bg = src.color._glBg; + // renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg); - renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg); + var transform = src.transform; + + renderer.spriteBatch.add( + 0, 0, + frame.cutWidth, frame.cutHeight, + 0, 0, 1, 1, + transform.world.tx, transform.world.ty, + transform._worldScaleX, transform._worldScaleY, + transform._worldRotation + ); }; module.exports = ImageWebGLRenderer; diff --git a/v3/src/renderer/webgl/WebGLRenderer.js b/v3/src/renderer/webgl/WebGLRenderer.js index dc1abd34c..aafd090ab 100644 --- a/v3/src/renderer/webgl/WebGLRenderer.js +++ b/v3/src/renderer/webgl/WebGLRenderer.js @@ -7,6 +7,7 @@ var CONST = require('../../const'); var CreateEmptyTexture = require('./utils/CreateEmptyTexture'); +var CreateTexture2DImage = require('./utils/texture/CreateTexture2DImage'); var BlitterBatch = require('./batches/blitter/BlitterBatch'); var SpriteBatch = require('./batches/sprite/SpriteBatch'); @@ -46,8 +47,10 @@ var WebGLRenderer = function (game) this.gl = null; this.init(); + this.blitterBatch = new BlitterBatch(game, this.gl, this); this.spriteBatch = new SpriteBatch(game, this.gl, this); + this.batch = null; this.currentTexture2D = null; }; @@ -133,6 +136,18 @@ WebGLRenderer.prototype = { ]; }, + createTexture2D: function (source) + { + var gl = this.gl; + + if (!source.glTexture) + { + source.glTexture = CreateTexture2DImage(gl, source.image, gl.NEAREST, 0); + } + + this.currentTexture2D = source.glTexture; + }, + setTexture2D: function (texture2D) { this.currentTexture = texture2D; diff --git a/v3/src/textures/TextureManager.js b/v3/src/textures/TextureManager.js index 17acfae3c..4de312818 100644 --- a/v3/src/textures/TextureManager.js +++ b/v3/src/textures/TextureManager.js @@ -18,8 +18,10 @@ var Texture = require('./Texture'); * @class Phaser.TextureManager * @constructor */ -var TextureManager = function () +var TextureManager = function (game) { + this.game = game; + this.list = {}; }; @@ -169,7 +171,6 @@ TextureManager.prototype = { this.list[key] = texture; return texture; - }, exists: function (key)