- Code: Select all
package com.android.gl2jni;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.WindowManager;
import java.io.File;
public class GL2JNIActivity extends Activity {
GL2JNIView mView;
@Override protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mView = new GL2JNIView(getApplication());
setContentView(mView);
setRequestedOrientation(0);
}
@Override protected void onPause() {
super.onPause();
mView.onPause();
}
@Override protected void onResume() {
super.onResume();
mView.onResume();
}
//the modified part
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
//return super.onTouchEvent(event);
mView.queueEvent(new Runnable() {
public void run() {
try {
Thread.sleep(33);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
return true;
}
}
This i to try to make the system lag less when i touch the screen continuously, I have seen this solution being used in other openGL apps on the android, although not with openGl ES 2.0. The problem is that my rendering freezes when call thread.sleep. But isn't it suppose to be in a separate thread that not effect the rendering thread?

