1

我正在尝试学习openGL-es,我正在学习一个简单的教程,但是当它应该在模拟器中运行时,我的程序崩溃了。

下面是我的主要活动:

public class MainActivity extends Activity {
private GLSurfaceView myGLView;

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

    requestWindowFeature(Window.FEATURE_NO_TITLE);      
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    myGLView = new GLSurfaceView(this);
    myGLView.setRenderer(new RenderG());
    setContentView(myGLView);
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    myGLView.onPause();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    myGLView.onResume();
}

}

这是我的渲染类波纹管:

public class RenderG implements Renderer {


@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    Log.d("GLSurfaceViewTest", "surface created");
}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    Log.d("GLSurfaceViewTest", "surface changed: " + width + "x" + height);
}

@Override
public void onDrawFrame(GL10 gl) {
    // TODO Auto-generated method stub
    Log.d("GLSurfaceViewTest", "onDrawFrame");
    gl.glClearColor(.5f, .5f, .5f, .5f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
}
}

那么它有什么问题呢?

4

0 回答 0