I am working on an Android NDK app that needs access to the pixels of an OpenGL ES 2.0 texture.
OpenGL extensions allow doing this as described e.g. here, here, and here.
All of these approaches require using the GraphicBuffer
class which is not a part of the NDK (see e.g. here). Apparently, this requires accessing a private C++ Android API (from the AOSP-Android Open Source Project).
First, if I actually build and link with the AOSP repo, will my app run on the same Android devices as the "pure"-NDK version?
Can anyone provide (ref. to) detailed instruction for how to do this and the pros/cons of doing this?
Second, Android's "Graphics architecture" document states:
ANativeWindow
The public Surface class is implemented in the Java programming language. The equivalent in C/C++ is the ANativeWindow class, semi-exposed by the Android NDK. You can get the ANativeWindow from a Surface with the ANativeWindow_fromSurface() call. Just like its Java-language cousin, you can lock it, render in software, and unlock-and-post.
To create an EGL window surface from native code, you pass an instance of EGLNativeWindowType to eglCreateWindowSurface(). EGLNativeWindowType is just a synonym for ANativeWindow, so you can freely cast one to the other.
and according to this GraphicBuffer
is a "simple wrapper" over ANativeWindowBuffer
.
So the second question is: Is it possible to create an OpenGL texture compatible surface like GraphicBuffer
by using only EGL and NDK functions (without requiring AOSP)? If so how?