How to detect touch events within a certain Renderer-area in android?
<p>In android I have taken a rotating sphere example <a href="https://bitbucket.org/jimcornmell/opengltexturedsphere" rel="noreferrer">given here</a>. It creates a simple app showing a rotating sphere (the earth).</p>

<p>Now, I want to do something if the rotating sphere is pressed on the phone display. I do not want to react to touch events <em>outside</em> of the rotating sphere. Here is what I have tried so far, by using a derived version of the <code>GLSurfaceView</code>:</p>

<pre><code>public class MyGLSurfaceView extends GLSurfaceView {



    MyGLSurfaceView(Context context) {
        super(context);
    }

    public boolean onTouchEvent(MotionEvent event) {
        int x = (int)event.getX();
        int y = (int)event.getY();
        Log.d("onTouchEvent",String.format("keyCode: %d  coords: %d  %d", event.getActionMasked(), x, y));

        Renderer renderer = this.Renderer.getRenderer(); // ERROR
        return super.onTouchEvent(event);
    }

}
</code></pre>

<p>Without the ERROR line this code works, and when I press the display I get the x/y coordinate. </p>

<p>However, in order to evaluate if the event was <em>within</em> the sphere, my approach was to get the renderer which has the <code>Sphere</code> object to determine if the x/y coordinates are within the sphere. </p>

<p>But the ERROR line does not work, I get an error saying </p>

<pre><code>Error:(26, 56) error: cannot find symbol method getRenderer()
</code></pre>

<p>How can I fix this error; or is there a more sane way to find out automatically if the event was on the <code>Sphere</code>-graphics-object?</p>

<p>Maybe it is a good idea to change the constructor and pass the renderer instance to <code>MyGLSurfaceView</code> as well? ADDENDUM: This idea does not seem to work. I get a constructor error I do not understand...</p>