let texture = spriteFrame.getTexture();
var rt= new cc.RenderTexture();
rt.initWithSize(texture.width, texture.height);
rt.drawTextureAt(texture, 0, 0);
var data = rt.readPixels(null);
rt.destroy();
报错信息:
[ERROR] (/Users/nantas/fireball-x/cocos2d-x-lite_22/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp, 1889): glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 ); GL error 0x506: GL_INVALID_FRAMEBUFFER_OPERATION
[ERROR] Failed to invoke JSB_glReadPixels, location: /Users/nantas/fireball-x/cocos2d-x-lite_22/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp:1893
at HTMLElement.print-simulator-log (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/scene/panel/messages/scene.js:1:1608)
at Object.e._dispatch (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/renderer/panel.js:1:1876)
at EventEmitter. (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/renderer/ipc.js:1:2952)
at EventEmitter.emit (events.js:194:13)