maccard
maccard

Reputation: 1258

Gestures and OpenGL

I'm using OpenGL ES on android 2.3.3 at the minute to render a simple 3D game. I'd like to extend it using the built in gestures library, but I can't find a way to recognise the gestures from a GLSurfaceView as opposed to an android view(I don't have an XML layout is what I'm saying) Is there any way to either implement an XML layout on top of what I have already, or preferably to implement the gestures library on top of the GLSurfaceview instead. Thanks.

Upvotes: 2

Views: 2201

Answers (2)

Jasoneer
Jasoneer

Reputation: 2078

The gesture library has a way of 'stealing' events from the view. See here for details.

Here, here, and here are some examples that should make it clearer.

Upvotes: 2

James Coote
James Coote

Reputation: 1973

You can attach a normal onTouchListener to GLSurfaceView, so long as you have an instance of GLSurfaceView (which it sounds like is what you have). This is only really useful if you just want to know the raw x,y coordinates on screen where the user has pressed (e.g to rotate around the y if the user moves their finger left/right across the screen)

For gesture library, which I haven't used myself, you should be able to just place your GLSurfaceView inside a frame layout and then place another view (e.g. linear layout set to match_parent) in the same frame layout so that it completely covers the GLSurfaceView and is on top of it. Attach the gesture library to this view (and obviously make sure it is transparent so people can still see the GLSurfaceView below).

Upvotes: 3

Related Questions