diff --git a/gulpfile.js b/gulpfile.js index f564f23579..e52b2aeb02 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -59,19 +59,19 @@ gulp.task('build-html5', ['build-html5-preview', 'build-html5-dev', 'build-html5 gulp.task('build-jsb-dev', function (done) { Engine.buildJsb([ - './index.js', + './jsb/index.js', ], './bin/jsb_polyfill.dev.js', [], done); }); gulp.task('build-jsb-min', function (done) { Engine.buildJsbMin([ - './index.js', + './jsb/index.js', ], './bin/jsb_polyfill.js', [], done); }); gulp.task('build-jsb-preview', function (done) { Engine.buildJsbPreview([ - './index.js', + './jsb/index.js', ], './bin/jsb_polyfill-for-preview.js', [], done); }); diff --git a/jsb/gfx.js b/jsb/gfx.js index 10c730a911..37fb392ecc 100644 --- a/jsb/gfx.js +++ b/jsb/gfx.js @@ -62,21 +62,36 @@ cc.defineGetterSetter(_p, "count", _p.getCount); gfx.VertexFormat = VertexFormat; Object.assign(gfx, enums); +function convertImages(images) { + if (images) { + for (let i = 0, len = images.length; i < len; ++i) { + let image = images[i]; + if (image !== null) { + if (image instanceof window.HTMLCanvasElement) { + if (image._data) { + images[i] = image._data._data; + } + else { + images[i] = null; + } + } + else if (image instanceof window.HTMLImageElement) { + images[i] = image._data; + } + } + } + } +} + _p = gfx.Texture2D.prototype; _p._ctor = function(device, options) { + convertImages(options.images); this.init(device, options); }; _p.destroy = function() { }; _p.update = function(options) { - if (options.images) { - for (let i = 0, len = options.images.length; i < len; ++i) { - let image = options.images[i]; - if (image != null && image._data) { - options.images[i] = image._data; - } - } - } + convertImages(options.images); this.updateBinding(options); }; cc.defineGetterSetter(_p, "_width", _p.getWidth); diff --git a/jsb/vertex-format-jsb.js b/jsb/vertex-format-jsb.js index 707c060647..d61910f4e5 100644 --- a/jsb/vertex-format-jsb.js +++ b/jsb/vertex-format-jsb.js @@ -59,7 +59,7 @@ class VertexFormat { normalize: (info.normalize === undefined) ? false : info.normalize, bytes: info.num * attrTypeBytes(info.type), }; - log('info.num is:' + info.num + ' attrTypeBytes(info.type) is:' + attrTypeBytes(info.type)); + // log('info.num is:' + info.num + ' attrTypeBytes(info.type) is:' + attrTypeBytes(info.type)); this._attr2el[el.name] = el; this._elements.push(el);