0

我刚刚开始学习openGL,并且正在研究android并且陷入困境。请看下面的代码:-

    public void onDrawFrame(GL10 arg0) {

    glClear(GL_COLOR_BUFFER_BIT);
}

@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {

    glViewport(0,0,width,height);
}

@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {

    glClearColor(1.0f,0.0f,0.0f,0.0f);
}

在 onSurfaceCreated 中设置颜色,在 onDrawFrame 中清除颜色缓冲区。现在一旦清除了颜色缓冲区,为什么表面的颜色仍然和 onSurfaceCreated 中设置的一样?

4

1 回答 1

1

glClearColor指定将用于清除缓冲区的颜色。当您调用glClear此颜色时,将应用到缓冲区。

如果您想要一个深色表面,请将其更改为:

 glClearColor(0.0f,0.0f,0.0f,0.0f);
于 2013-07-26T19:50:58.937 回答