- Home /
glReadPixels crashes
I'm implementing glReadPixels attached to an orthographic camera. However, 3-5 seconds after the execution, Unity Editor crashes. I think it has something to do with the FrameBuffer or memory allocation Here it is my implementation:
onAwake():
renderTex = new RenderTexture(20, 20, 20, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
RenderTexture.active = renderTex;
GetComponent<Camera>().targetTexture = renderTex;
onUpdate():
information=new byte[20*20*4];
unmanagedPointer = Marshal.AllocHGlobal(information.Length);
Marshal.Copy(information, 0, unmanagedPointer, information.Length);
GetComponent<Camera>().Render();
Marshal.FreeHGlobal(unmanagedPointer);
onPostRender():
glReadPixels (0, 0, 20, 20, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, unmanagedPointer);
Crash report:
6 libGPUSupport.dylib 0x00000001188a627d
gpulCheckForFramebufferIOSurfaceChanges + 54
7 libGPUSupport.dylib 0x00000001188a6202 gldUpdateReadFramebuffer + 42
8 GLEngine 0x00007fff9247e01c gleUpdateReadFramebufferState + 425
9 GLEngine 0x00007fff923ac751 glReadPixels_Exec +
Comment
Your answer
Follow this Question
Related Questions
Switching VR platforms via VRSettings 0 Answers
OpenGL 2.0 or 3.0 for newer iOS 0 Answers
gpus_ReturnNotPermittedKillClient crashes on iOS 1 Answer
Play video using native code in Unity3d via NDK 0 Answers
Crash running unity 5 on opengl mode 0 Answers