入力処理を別のスレッドで実行する方法は?私はこのようなハロー-GL2例を変更しました:アンドロイドでの入力処理、つまり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