Skip to content Skip to sidebar Skip to footer

Android, Opengl Lag In Jni When Touching Screen

I am currently testing out all the features that a need in my game on the Android platform. I have only modified the hello-gl2 sample code, and added some textures, VBO's, FBO's an

Solution 1:

I'm fairly new to android development but found the touch handler to be very laggy also. The default sample is newing up an object and doing this quite a lot - this is bound to make the garbage collector angry. I managed to get it to perform in a less laggy way by calling 'Thread.sleep(10);' inside the run function.

I imagine that replacing the 'new Runnable' with a circular buffer of objects would improve performance but I haven't investigated this yet. I'm the touch events seem to occur on a seperate thread and this may cause complications.

Override public boolean onTouchEvent(final MotionEvent event)
    {
        queueEvent(


        new Runnable()
        {
            publicvoidrun()
            {

                int action = event.getAction();
                //do your handling heretry
                {
                    Thread.sleep(10);
                } catch (InterruptedException e)
                {

                    e.printStackTrace();
                } 

            }
        });
        returntrue;
    }

Post a Comment for "Android, Opengl Lag In Jni When Touching Screen"