0

我正在尝试在此页面上关注有关 opengl es 2.0 android 的教程。

让我抓狂的是视图的初始化。请看下面的代码:

// Our OpenGL Surfaceview
private GLSurfaceView glSurfaceView;

@Override
protected void onCreate(Bundle savedInstanceState) {

    // Turn off the window's title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // Super
    super.onCreate(savedInstanceState);

    // Fullscreen mode
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // We create our Surfaceview for our OpenGL here.
    glSurfaceView = new GLSurf(this);

    // Set our view.    
    setContentView(R.layout.activity_main);

    // Retrieve our Relative layout from our main layout we just set to our view.
    RelativeLayout layout = (RelativeLayout) findViewById(R.id.gamelayout);

    // Attach our surfaceview to our relative layout from our main layout.
    RelativeLayout.LayoutParams glParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    layout.addView(glSurfaceView, glParams);
}

@Override
protected void onPause() {
    super.onPause();
    glSurfaceView.onPause();
}

@Override
protected void onResume() {
    super.onResume();
    glSurfaceView.onResume();
}

我没有在这里得到 addview 过程。将内容视图设置为activity_main,然后在没有任何关系的情况下将glSurfaceview 添加到relativeLayout。

这不应该是某种关系吗?

4

0 回答 0