Skip to content

Commit

Permalink
Init zero-data texture on resize
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed May 15, 2018
1 parent 127e0a0 commit 85bef7d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ module.exports = function createTextureSet (
}

function setFlags (flags) {
// FF warning here https://bugzilla.mozilla.org/show_bug.cgi?id=1400077
gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY)
gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha)
gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace)
Expand Down Expand Up @@ -841,7 +842,9 @@ module.exports = function createTextureSet (
target, miplevel, format, info.xOffset, info.yOffset, width, height, 0)
} else {
var nullData = !data
if (nullData) data = pool.zero.allocType(type, width * height * channels)
if (nullData) {
data = pool.zero.allocType(type, width * height * channels)
}

gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data)

Expand Down Expand Up @@ -1331,10 +1334,16 @@ module.exports = function createTextureSet (
reglTexture2D.height = texture.height = h

tempBind(texture)

var data
var channels = texture.channels
var type = texture.type

for (var i = 0; texture.mipmask >> i; ++i) {
var _w = w >> i
var _h = h >> i
if (!_w || !_h) break
data = pool.zero.allocType(type, _w * _h * channels)
gl.texImage2D(
GL_TEXTURE_2D,
i,
Expand All @@ -1344,7 +1353,8 @@ module.exports = function createTextureSet (
0,
texture.format,
texture.type,
null)
data)
pool.zero.freeType(data)
}
tempRestore()

Expand Down

0 comments on commit 85bef7d

Please sign in to comment.