3

I'm building an audio / music app. in Android. And because of this I'm using the new Oboe C++ library.

I'm wondering how people do graphics and UI in Android with NDK applications.

I don't think I need OpenGL or a low level, fast graphics library. This isn't a game. I really just need to pick up different touches in different locations / from some custom UI widgets. (But I do need multitouch).

Is there a convenient highish-level API for doing the drawing and picking up touches from C++? If so, what is it? Or would I be better doing all the UI in Java and just calling down to the NDK for the audio?

This is the first time I'm trying to work with Android NDK and the Oboe examples I've looked at don't really draw anything in C++. The one "hello world" example, uses Java widgets. And the others don't really draw anything on the screen at all.

interstar
  • 26,048
  • 36
  • 112
  • 180
  • Take a look at the Oboe RhythmGame codelab, it uses OpenGL for UI rendering. https://github.com/google/oboe/blob/master/samples/RhythmGame/README.md – donturner Nov 04 '19 at 13:46
  • Yeah. I'm using that as the basis of my code. But it's not multi-touch. My question was precisely how to go beyond what they do in that game. – interstar Nov 07 '19 at 00:23

1 Answers1

2

To be clear, Multitouch events are handled and made available by the Java/Kotlin side of the Android Framework so you would need to pass those down through the JNI level. A reason to draw at the NDK layer is to reduce the latency of passing a result back up through the JNI layer to the Java/Kotlin layer which would have to update any widget/view.

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • 2
    What I would do is, create a JNI layer for all the Oboe methods, needed and then code everything UI to handling touch event in Kotlin. But yeah, if you are doing that, why not just use https://developer.android.com/reference/android/media/AudioTrack in Java/Kotlin – Pulkit Jul 11 '19 at 20:49