diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-06-14 10:28:45 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-06-14 10:28:45 -0700 |
commit | e0f544e7e4c555eba79d6e136798c9388e3b0c04 (patch) | |
tree | 68132ccc5754ef49c762f4bed2a14885d72c2b31 | |
parent | fe747c80102d2d07a0372b40bc3afbced3d8f05c (diff) |
init texture compression early
-rw-r--r-- | src/library_gl.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 9928ab5d..86be9aa6 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -4,6 +4,7 @@ */ var LibraryGL = { + $GL__postset: 'GL.init()', $GL: { #if GL_DEBUG debug: true, @@ -21,6 +22,10 @@ var LibraryGL = { packAlignment: 4, // default alignment is 4 bytes unpackAlignment: 4, // default alignment is 4 bytes + init: function() { + Browser.moduleContextCreatedCallbacks.push(GL.initCompression); + }, + // Linear lookup in one of the tables (buffers, programs, etc.). TODO: consider using a weakmap to make this faster, if it matters scan: function(table, object) { for (var item in table) { @@ -102,9 +107,9 @@ var LibraryGL = { ((height - 1) * alignedRowSize + plainRowSize); }, - ensureCompression: function() { - if (GL.ensureCompression.done) return; - GL.ensureCompression.done = true; + initCompression: function() { + if (GL.initCompression.done) return; + GL.initCompression.done = true; var ext = Module.ctx.getExtension('WEBGL_compressed_texture_s3tc') || Module.ctx.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || @@ -284,7 +289,6 @@ var LibraryGL = { }, glCompressedTexImage2D: function(target, level, internalformat, width, height, border, imageSize, data) { - GL.ensureCompression(); if (data) { data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { @@ -294,7 +298,6 @@ var LibraryGL = { }, glCompressedTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, imageSize, data) { - GL.ensureCompression(); if (data) { data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { |