OpenGL in NDK without GLSurfaceView

990 views
Skip to first unread message

Rémi

unread,
Jun 10, 2011, 11:32:39 AM6/10/11
to andro...@googlegroups.com
Hi,
In my application I would like to have more control over OpenGL and EGL to present the renderbuffer, etc...
Right now I create a GLSurfaceView and pass the render call to the NDK who then do the necessary OpenGL calls.
I've looked at the NativeActivity sample, and I would like to have as much control over OpenGL but I need to have a Java side too, so NativeActivity doesn't work for me.
The problem I am facing is how to create the window so it gets display on screen. Basically, how do I get the window object necessary to create the window surface, to do the equivalent as (from NativeActivity sample) :

    eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
    ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
    surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);

Is what I'm trying to do even possible?
Thanks

Tim Mensch

unread,
Jun 10, 2011, 1:04:54 PM6/10/11
to andro...@googlegroups.com
On 6/10/2011 9:32 AM, Rémi wrote:
> In my application I would like to have more control over OpenGL and
> EGL to present the renderbuffer, etc...
> Right now I create a GLSurfaceView and pass the render call to the NDK
> who then do the necessary OpenGL calls.

GLSurfaceView is open source. You can, at a minimum, start with the
GLSurfaceView source imported into your application, and modify it from
there until you get to the point where it does exactly what you want.

Picking a VERSION of GLSurfaceView to start with is left as an exercise
for the reader. :)

Tim

Dianne Hackborn

unread,
Jun 12, 2011, 6:47:12 PM6/12/11
to andro...@googlegroups.com
You can most certainly use Java code with NativeActivity.  Just implement your subclass of NativeActivity...  or just use JNI from your native code to all back in to whatever Java code you want.

If you mean you want to mix a regular view hierarchy with Java code than you can just use a plain SurfaceView and your own version of GLSurfaceView's code, as Tim suggests, to do what you want.  You can also use a SurfaceView and the 2.3 ANativeWindow_fromSurface() API to retrieve the native window of the Surface object you get from SurfaceView.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/s0mzXWEndl0J.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Rémi Chaignon

unread,
Jun 13, 2011, 12:53:18 PM6/13/11
to andro...@googlegroups.com
Thanks for your help, I will dig deeper.
Reply all
Reply to author
Forward
0 new messages