0
我在這裏要做的是加載一個OpenGL上下文,當我點擊主活動中的列表視圖項時。從列表視圖項加載OpenGL點擊
看起來很簡單!但我真的不知道如何將主要活動與OpenGL活動連接起來。任何人都可以給我一些提示嗎?
謝謝!
編輯:ADD這裏一些代碼:
在主要活動:
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)
和應用程序「不幸的是停止」
像普通視圖一樣創建[GLSurfaceView](http://developer.android.com/reference/android/opengl/GLSurfaceView.html)並設置渲染器。 –
@MarcinGawel是的,但我真的不知道我在做什麼錯在這裏,添加代碼段 – Imemmaw
任何錯誤或發生了什麼? –