如何使输入处理在单独的线程中运行?我已经像这样修改了 hello-gl2 示例:
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;
}
}
当我连续触摸屏幕时,我试图减少系统延迟,我已经看到这个解决方案被用于 android 上的其他 openGL 应用程序,尽管没有使用 openGl ES 2.0。问题是调用thread.sleep时我的渲染冻结了。但是它不是假设在一个不影响渲染线程的单独线程中吗?