3
我已經遵循google的位於here的onTouch示例。但是,我的日誌裏沒有任何東西出來。據我所知,我的觀點並沒有提到任何觸摸事件。這是我的代碼:GLSurfaceview沒有獲取onTouch事件
package com.test;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
public class intro extends Activity {
static{
System.loadLibrary("graphrender");
}
private GLSurfaceView mGLView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mGLView = new GraphGLSurfaceView(this);
setContentView(mGLView);
}
@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}
@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}
}
class GraphGLSurfaceView extends GLSurfaceView {
GraphRenderer mRenderer;
public GraphGLSurfaceView(Context context) {
super(context);
mRenderer = new GraphRenderer();
setRenderer(mRenderer);
}
public boolean onTouch(View v, MotionEvent event)
{
queueEvent(new Runnable(){
public void run() {
mRenderer.shout();
}});
return true;
}
}
class GraphRenderer implements GLSurfaceView.Renderer {
private static native void nativeSetup();
private static native void nativeSize(int w, int h);
private static native void nativeRender();
private float _red = 0.9f;
private float _green = 0.2f;
private float _blue = 0.2f;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeSetup();
Log.d("intro", "Got to intro 4");
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
nativeSize(w,h);
}
public void onDrawFrame(GL10 gl) {
nativeRender();
}
public void shout()
{
Log.d("Graph Page", "gotta graph");
}
}
我能想到的唯一的事情就是我必須在XML文件中的東西花哨或設置其重點。任何幫助,將不勝感激。
嗨,我試過這種方法,我一直有類似的問題,但它似乎像現在我得到的觸摸事件,除了實際GLsurfaceView ... – ekatz 2012-03-01 15:55:56