How do you get ANativeWindow from SurfaceTexture in NDK

I have OpenGL ES code that was rendering for GLSurfaceView , and now I'm modifying it to work with SurfaceView and TextureView .

A common element that I need from within my own code is: ANativeWindow .

For SurfaceView I got it by passing Surface to:

 m_jwindow = ANativeWindow_fromSurface(env, surface); 

For TextureView I take SurfaceTexture , and in API 14 I can use this:

 m_jwindow = ANativeWindow_fromSurfaceTexture(env, surface); 

However, this feature has been removed in Jellybean. Why am I wondering how I can get ANativeWindow from SurfaceTexture in API SurfaceTexture ?

+6
source share
1 answer

What you need to do in API 16+ is to create a Surface object, passing the SurfaceTexture as an argument to the constructor (which was introduced in API 14). Pass this surface to ANativeWindow_fromSurface() , as usual.

+8
source

Source: https://habr.com/ru/post/971069/


All Articles