在native上怎么获取,我获取的时候都报错
模拟器上我用的textureRender 方式,会报错
var rt = dataContainer
if (!rt){
rt = new cc.RenderTexture()
rt.initWithSize(tex.width, tex.height)
rt.drawTextureAt(tex, 0, 0)
_textureIdMapDataContainer[tex.getId()] = rt
}
// data就是这个texture的rgba值数组
if (spriteFrame.isRotated()) {
data = rt.readPixels(null, rect.x + posInRect.y, rect.y + posInRect.x, 1, 1)
//cc.log(type + "--", "data", data, rect.x + posInRect.y, rect.y + posInRect.x)
}
else {
data = rt.readPixels(null, rect.x + posInRect.x, rect.y + rect.height - posInRect.y, 1, 1)
//cc.log(type + "--", "data", data, rect.x + posInRect.x, rect.y + rect.height - posInRect.y)
}
Simulator: [ERROR] (/Users/nantas/fireball-x/cocos2d-x-lite_21/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp, 1888): 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_21/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp:1892
at HTMLElement.print-simulator-log (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/scene/panel/messages/scene.js:1:1669)
at Object.e._dispatch (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/renderer/panel.js:1:1941)
at EventEmitter.o.on.s (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/renderer/ipc.js:1:2921)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:204:7)