unity android surface,安卓surfacetexture用unity显示
該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓
那就是這樣?
//先給 生成個 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);
//接著 創(chuàng)建個 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);
總結
以上是生活随笔為你收集整理的unity android surface,安卓surfacetexture用unity显示的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java多线程【三种实现方法】
- 下一篇: web课设 thinkphp5+mySQ