To get quick access to OpenGL ES 2.0 texture pixels on the Android NDK, I want to use the eglCreateImageKHR() extension.
According to the EGL_NATIVE_BUFFER_ANDROID docs :
This extension allows you to use the Android window buffer (struct ANativeWindowBuffer ) as an EGLImage source.
ANativeWindowBuffer is an internal struct used by built-in infrastructure classes such as GraphicBuffer . Unfortunately, since I am in the NDK, I do not have direct access to these classes.
NDK's native_window allows native_window to pass a Java Surface object through the NDK. Then I can use ANativeWindow_fromSurface() to get the opaque handle ANativeWindow* . With this pointer, I can call ANativeWindow_lock() to populate a structure of type ANativeWindow_Buffer (Note _ ).
If I try to use this &ANativeWindow_Buffer object with eglCreateImageKHR() , it fails with EGL_BAD_NATIVE_WINDOW .
My question is: how can I use ANativeWindow_Buffer with eglCreateImageKHR() or, alternatively, how to get ANativeWindowBuffer from ANativeWindow_Buffer or from ANativeWindow* .
source share