如何在Android的冰淇淋三明治替代GLSurfaceView与TextureView?明治、冰淇淋、如何在、TextureView

2023-09-04 11:05:45 作者:玫瑰虽美'但却刺入骨髓

的TextureView 文档说,它可以被用于呈现内容的OpenGL。

The TextureView documentation states that it can be used to render OpenGL content.

在博客文章宣布TextureView,它规定

In the blog post announcing TextureView, it states:

一个TextureView可以很方便地用来嵌入OpenGL场景在你的应用程序。由于Android 4.0,eglCreateWindowSurface()可以用来渲染成一个物体表面纹理。

A TextureView can just as easily be used to embed an OpenGL scene in your application. As of Android 4.0, eglCreateWindowSurface() can be used to render into a SurfaceTexture object.

这似乎意味着,要使用,而不是GLSurfaceView TextureView,一会做所有的EGL设置本身和管理EGLContext和线程(因为GLSurfaceView保持GLThread)。似乎没有被任何样品code在Android 4.0 SDK,演示如何在 TextureView可以很方便地用来嵌入OpenGL场景的。 TextureView似乎更干净插入到相机preVIEW(套previewTexture)和MediaPlayer的(setSurface)。

Which seems to imply that to use TextureView instead of GLSurfaceView, one would have to do all the EGL setup themselves and manage the EGLContext and the threading (since GLSurfaceView maintains a GLThread). There doesn't seem to be any sample code in the Android 4.0 SDK that demonstrates how the "TextureView can just as easily be used to embed an OpenGL scene". TextureView seems to plug in more cleanly to the Camera preview (setPreviewTexture) and MediaPlayer (setSurface).

时有可能使用GLSurfaceView与TextureView结合使用GLSurfaceView.setEGLWindowSurfaceFactory使其呈现到TextureView的表面纹理?

Is it possible to use GLSurfaceView in conjunction with TextureView by using GLSurfaceView.setEGLWindowSurfaceFactory to make it render to the TextureView's SurfaceTexture?

此外,这将是很好,如果有一些样品code。

Again, it would be nice if there were some sample code.

推荐答案

请参阅罗曼盖伊的回答对android-dev的谷歌组:

See Romain Guy's answer on the android-dev google group:

http://groups.google.com/group/android-developers/browse_thread/thread/539457146a401cf1