Unable to call glReadPixels from a managed plugin.
Hello everyone.
I've got a problem using GLES20 calls from within a managed code java plugin . The desired goal is to get the render result of a camera in java without going through Texture2d.ReadPixels() in the managed C#, to avoid memory allocation.
Currently what i've attempted has been to do the following :
public RenderTexture JavaOutputTex;
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if(JavaOutputTex == null) {
JavaOutputTex = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.ARGB32);
}
Graphics.Blit(src, JavaOutputTex, material);
JavaPlugin.SetImage(JavaOutpuTex.GetNativeTexturePtr());
.
.
Graphics.Blit(src, dest);
}
On the C# side and on the Java Side:
void ProcessRenderOutput(int textureID) {
GLBuffer = ByteBuffer.allocateDirect(RGBLength).order(ByteOrder.nativeOrder());
boolean isFBO = GLES20.glIsFramebuffer(textureID); // Evaluates to True
boolean isTex = GLES20.glIsTexture(textureID); // Evaluates to True
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, textureID);
GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, GLBuffer);
}
Whenever i check what the issue might be here I always get the same error - GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT.
Can anyone shed some light on what i'm missing? I'm not using Multithreaded rendering and i've forced GL ES2.0 graphics API to on.
Any help would be appreciated!
Your answer
![](https://koobas.hobune.stream/wayback/20220612140849im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to create plugin with network suff (NetwrokBehaviour, SyncVar etc) ? 0 Answers
Is it possible to access rig joints in C#? 0 Answers
Cant build the Holo World sample as Unity has errors... 0 Answers
Android plugin - how to create a daily notification 0 Answers
Android Plugin Jar java.lang.ClassNotFoundException 0 Answers