我使用cc.RenderTexture.create创建RT,在模拟器和浏览器下都能正常工作。导出微信小游戏的工程后会报以下错误
Failed to execute 'texImage2D' on 'WebGLRenderingContext': No function was found that matched the signature provided.
TypeError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': No function was found that matched the signature provided.
at CCClass.216.game.once._p._setImage (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:38169:189)
at CCClass.216.game.once._p.update (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:38152:22)
at CCClass.216.game.once._p.initWithData (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:38191:18)
at 269.cc.RenderTexture.WebGLRenderCmd.269.proto.initWithWidthAndHeight (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:46449:18)
at TheClass.initWithWidthAndHeight (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:46208:32)
at TheClass.ctor (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:46175:16)
at new TheClass (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:32903:16)
at Function.267.cc.RenderTexture.create (http://127.0.0.1:54271/game/cocos2d-js.071b3.js:46289:14)
看了一下代码,是gl.texImage2D调用时候出错
if ( sys.platform === sys.WECHAT_GAME ||
sys.platform === sys.QQ_PLAY ||
img instanceof HTMLCanvasElement ||
img instanceof HTMLImageElement ||
img instanceof HTMLVideoElement
) {
gl.texImage2D(
gl.TEXTURE_2D,
0,
glFmt.internalFormat,
glFmt.format,
glFmt.pixelType,
img
);
}
有哪位大侠知道怎么解决这个问题吗?