如何使輸入處理在單獨的線程中運行?我已經修改了HELLO-GL2例子是這樣的:在android上處理輸入問題,即在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時,我的渲染凍結。但是,它不是假設在不影響渲染線程的單獨線程中嗎?
感謝您的回答!我看到了問題。我真正的問題是這樣的:http://stackoverflow.com/questions/5237414/android-opengl-lag-in-jni-when-touching-screen。這只是一個嘗試擺脫這個問題的小實驗。我猜你不知道輸入延遲問題的「銀彈」? – Mockarutan 2011-03-13 01:26:33