fix some bugs to run on native

This commit is contained in:
minggo
2018-03-30 16:35:30 +08:00
parent d2dbd72f34
commit 19a1354c9a
3 changed files with 27 additions and 12 deletions
+3 -3
View File
@@ -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);
});
+23 -8
View File
@@ -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);
+1 -1
View File
@@ -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);