0

ここでやろうとしているのは、メイン アクティビティでリストビューの項目をクリックしたときに OpenGL コンテキストを読み込むことです。

見た目通りシンプル!しかし、メイン アクティビティを OpenGL アクティビティに接続する方法が本当にわかりません。誰でもヒントを教えてもらえますか?

ありがとうございました!!

編集:ここにいくつかのコードを追加します:

主な活動:

listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

            Intent launchGL = new Intent(getApplicationContext(), OpenGLActivity.class);  
            startActivity(launchGL);

            }
        });

OpenGLActivity では:

public class OpenGLActivity extends Activity {

private GLSurfaceView mGLSurfaceView;

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    mGLSurfaceView = new GLSurfaceView(this);

    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

    if (supportsEs2)
    {
        // Request an OpenGL ES 2.0 compatible context.
        mGLSurfaceView.setEGLContextClientVersion(2);

        // Set the renderer to our demo renderer, defined below.
        mGLSurfaceView.setRenderer(new MyRenderer());
    }
    else
    {
        // This is where you could create an OpenGL ES 1.x compatible
        // renderer if you wanted to support both ES 1 and ES 2.
        return;
    }

    setContentView(mGLSurfaceView);
}

}

(実験用のチュートリアルコードを使用)

エラーメッセージ:

07-19 19:59:06.945: E/AndroidRuntime(1451): FATAL EXCEPTION: GLThread 108
07-19 19:59:06.945: E/AndroidRuntime(1451): java.lang.IllegalArgumentException: No configs match configSpec
07-19 19:59:06.945: E/AndroidRuntime(1451):     at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:863)
07-19 19:59:06.945: E/AndroidRuntime(1451):     at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)
07-19 19:59:06.945: E/AndroidRuntime(1451):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)
07-19 19:59:06.945: E/AndroidRuntime(1451):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

そしてアプリ「残念ながら停止」

4

1 に答える 1

0

エミュレーターでコードを実行する場合は、「use host gpu」を有効にしてみてください。または、可能であれば、実際のデバイスで試してみてください。エミュレーターは、実際のデバイスよりもはるかに遅いため、openGl のものにはかなり悪い考えです。

于 2013-07-19T20:26:36.763 に答える