Skip to content

Commit 649378e

Browse files
committed
Tidied up canvas creation and texture deletion
1 parent e3c28d3 commit 649378e

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/renderer/webgl/WebGLRenderer.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
var Class = require('../../utils/Class');
99
var CONST = require('../../const');
1010
var IsSizePowerOfTwo = require('../../math/pow2/IsSizePowerOfTwo');
11+
var SpliceOne = require('../../utils/array/SpliceOne');
1112
var Utils = require('./Utils');
1213
var WebGLSnapshot = require('../snapshot/WebGLSnapshot');
1314

@@ -1297,6 +1298,13 @@ var WebGLRenderer = new Class({
12971298
*/
12981299
deleteTexture: function (texture)
12991300
{
1301+
var index = this.nativeTextures.indexOf(texture);
1302+
1303+
if (index !== -1)
1304+
{
1305+
SpliceOne(this.nativeTextures, index);
1306+
}
1307+
13001308
this.gl.deleteTexture(texture);
13011309

13021310
return this;
@@ -1555,9 +1563,7 @@ var WebGLRenderer = new Class({
15551563
* @since 3.0.0
15561564
*
15571565
* @param {HTMLCanvasElement} srcCanvas - [description]
1558-
* @param {WebGLTexture} dstTexture - [description]
1559-
* @param {boolean} shouldReallocate - [description]
1560-
* @param {integer} scaleMode - [description]
1566+
* @param {WebGLTexture} [dstTexture] - [description]
15611567
*
15621568
* @return {WebGLTexture} [description]
15631569
*/
@@ -1580,16 +1586,10 @@ var WebGLRenderer = new Class({
15801586
{
15811587
this.setTexture2D(dstTexture, 0);
15821588

1583-
// if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height)
1584-
// {
1585-
// gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas);
1586-
// }
1587-
// else
1588-
{
1589-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas);
1590-
dstTexture.width = srcCanvas.width;
1591-
dstTexture.height = srcCanvas.height;
1592-
}
1589+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas);
1590+
1591+
dstTexture.width = srcCanvas.width;
1592+
dstTexture.height = srcCanvas.height;
15931593

15941594
this.setTexture2D(null, 0);
15951595
}

0 commit comments

Comments
 (0)