var Utils = require('../../renderer/webgl/Utils'); var RenderTextureWebGL = { fill: function (rgb, alpha){ if (alpha === undefined) { alpha = 1; } var ur = ((rgb >> 16) | 0) & 255; var ug = ((rgb >> 8) | 0) & 255; var ub = (rgb | 0) & 255; this.renderer.setFramebuffer(this.framebuffer); var gl = this.gl; gl.clearColor(ur / 255, ug / 255, ub / 255, alpha); _AN_Call_clear('clear', gl, gl.COLOR_BUFFER_BIT); this.renderer.setFramebuffer(null ); return this; } , clear: function (){ this.renderer.setFramebuffer(this.framebuffer); var gl = this.gl; gl.clearColor(0, 0, 0, 0); _AN_Call_clear('clear', gl, gl.COLOR_BUFFER_BIT); this.renderer.setFramebuffer(null ); return this; } , draw: function (stamp, x, y, tint){ if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } if (!Array.isArray(stamp)) { stamp = [stamp] ; } this.renderer.setFramebuffer(this.framebuffer); var pipeline = this.pipeline; pipeline.projOrtho(0, this.width, 0, this.height, -1000, 1000); for (var i = 0; i < _AN_Read_length('length', stamp); i++ ){ if (stamp[i].frame) { this.drawGameObject(stamp[i], x, y); } { this.drawFrame(stamp[i], x, y, tint); } } pipeline.flush(); this.renderer.setFramebuffer(null ); pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000, 1000); return this; } , drawGameObject: function (gameObject, x, y){ var getTint = Utils.getTintAppendFloatAlpha; this.pipeline.batchTextureFrame(gameObject, gameObject.frame, x, y, gameObject.width, gameObject.height, gameObject.scaleX, gameObject.scaleY, gameObject.rotation, gameObject.flipX, gameObject.flipY, gameObject.displayOriginX, gameObject.displayOriginY, getTint(gameObject._tintTL, this.alpha * gameObject._alphaTL), getTint(gameObject._tintTR, this.alpha * gameObject._alphaTR), getTint(gameObject._tintBL, this.alpha * gameObject._alphaBL), getTint(gameObject._tintBR, this.alpha * gameObject._alphaBR), (gameObject._isTinted && gameObject.tintFill), null ); } , drawFrame: function (frame, x, y, tint){ if (tint === undefined) { tint = (this.globalTint >> 16) + (this.globalTint & 65280) + ((this.globalTint & 255) << 16); } else { tint = (tint >> 16) + (tint & 65280) + ((tint & 255) << 16); } this.pipeline.drawTextureFrame(frame, x, y, tint, this.globalAlpha, this.currentMatrix, null ); } } ; module.exports = RenderTextureWebGL;