Using the new NDK r5 function ANativeWindow_fromSurface()

2,172 views
Skip to first unread message

MagSoft

unread,
Dec 7, 2010, 10:20:33 AM12/7/10
to android-ndk
Hello,


I am trying to use the new NDK r5 function ANativeWindow_fromSurface()
to draw natively on a android.view.SurfaceView.
I get a valid reference to an ANativeWindow representing my
SurfaceView using this function. Indeed, I can get its correct size
using ANativeWindow_getHeight() and ANativeWindow_getWidth().
But drawing doesn't work, neither using OpenGLES as in the native-
activity sample nor ANativeWindow_lock() and
ANativeWindow_unlockAndPost().

Is was I am trying to do possible?
If yes, is there special flags to set to SurfaceView to enable native
drawing?
Is there some example somewhere?

Thank you,


--
MagSoft

shimimana

unread,
Jul 5, 2011, 6:00:02 AM7/5/11
to andro...@googlegroups.com
Since I encountered similar situation and I could solved, I commented.

- It should not be "SurfaceView" but "Surface" (android.view.Surface)
- Do not set type by SurfaceHolder#setType.
  (the API is deprecated but at least Android 2.3.3 it prevents from locking the surface.)

I'm wondering Surface#setFlags may also prevent from locking, but I didn't try.
I hope this helps.

Reply all
Reply to author
Forward
0 new messages