问题描述
我有一些OpenGL ES的code已被渲染到 GLSurfaceView
,和我目前正在修改它与任何<$ C $工作C> SurfaceView 和 TextureView
。
I've got some OpenGL ES code that has been rendering to a GLSurfaceView
, and I'm currently modifying it to work with either SurfaceView
and TextureView
.
我需要从内外我的祖国code的共同点是: ANativeWindow
The common element I need from both inside my native code is: ANativeWindow
.
对于 SurfaceView
我通过传递表面
来得到它:
For the SurfaceView
I got it by passing Surface
to:
m_jwindow = ANativeWindow_fromSurface(env, surface);
有关 TextureView
,我把表面纹理
,并在14 API,我可以用这样的:
For TextureView
, I take SurfaceTexture
, and in API 14 I can use this:
m_jwindow = ANativeWindow_fromSurfaceTexture(env, surface);
不过,该功能辗转于杰利贝恩。这让我想知道,我怎么能得到 ANativeWindow
从表面纹理
在API 16 +?
However, that function was removed in Jellybean. Which leaves me wondering, how can I get ANativeWindow
from a SurfaceTexture
in API 16+?
推荐答案
您需要做的API 16+什么是创建一个表面对象,传递的表面纹理作为参数传递给构造(这是在API 14中引入)。传递曲面到 ANativeWindow_fromSurface()
和往常一样。
What you need to do in API 16+ is create a Surface object, passing the SurfaceTexture as an argument to the constructor (which was introduced in API 14). Pass that Surface to ANativeWindow_fromSurface()
as usual.
这篇关于你如何从一个NDK获得表面纹理ANativeWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!