Reputation: 1917
I have a little issue that I am trying to solve.
Basically I am creating a EGL context with the NDK something similar to this: http://developer.android.com/reference/android/app/NativeActivity.html
In android if you extend surfaceview.renderer
, it also creates an EGL context behind the scenes after the onCreated
& onSurfaceChange
calls. You can see more here: http://developer.android.com/reference/android/opengl/GLSurfaceView.Renderer.html
My question is, since I am creating my EGL context within the native Activity but I need to access some lifecycle functions from the Java side. Is it possible to pass my EGL context from the native Activity and use it to setup a android surfaceview.renderer
and then use the glsurfaceview.renderer
to call back to native with JNI calls?
Upvotes: 1
Views: 1086
Reputation: 52353
You're going about it the wrong way.
The point of GLSurfaceView is to combine a SurfaceView with some code that takes care of EGL context and thread management for you. If you're doing your own EGL setup, and you don't mind dealing with the threading issues, there's no reason to use a GLSurfaceView -- and doing so makes things more complicated.
If you want to create and manage your own EGL context, use a plain SurfaceView. Create an EGLSurface from the SurfaceView's Surface.
If you prefer GLSurfaceView, don't create a separate EGL context. Just use the one that GLSurfaceView creates for you. Understand that it will be destroyed and recreated when the Activity pauses.
Upvotes: 3