那就是这样?
//先给 生成个 SurfaceTexture 并为他 生成个 纹理ID
int SurfaceTextureId;
int[] SurfaceIdContainer = new int[1]
GLES20.glGenTextures(1, SurfaceIdContainer, 0);
SurfaceTextureId=textureIdContainer[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,SurfaceTextureId);
texture=new SurfaceTexture(SurfaceTextureId);
texture.setOnFrameAvailableListener(this);
//再来个 texture2d
int TextureId;
int[] textureIdContainer = new int[1]
GLES20.glGenTextures(1, textureIdContainer, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureIdContainer[0]);
TextureId=textureIdContainer[0];
然后这个 TextureId 传给 unity 调用外部纹理
Texture2D.CreateExternalTexture(Screen.width, Screen.height, TextureFormat.BGRA32, false,false, (IntPtr)textureId);
//接着 创建个 FBO
int handle[] = { 0 };
GLES20.glGenFramebuffers(1, handle, 0);
int mFrameBufferID = handle[0];
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBufferID);
//然后就等 onFrameAvailable调用时 在里面
texture.updateTexImage();
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBufferID);
//把SurfaceTexture 的纹理加到这个 FBO ?
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, SurfaceTextureId, 0);
//然后绑定那个2D 图片?
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, TextureId);