Student Student
Student Student

Reputation: 960

Android OpenGL ES2 imports for renderer?

I'm new to Open GL ES2.I want to create a sample renderer.I override this method:

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
}

Then I got this error:

The method glClearColor(float, float, float, float) is undefined for the type

I try ctrl+shift+o but no thing happend.Until I add these lines to imports:

import static android.opengl.GLES20.GL_COLOR_BUFFER_BIT;
import static android.opengl.GLES20.glClear;
import static android.opengl.GLES20.glClearColor;
import static android.opengl.GLES20.glViewport;

And error rmoved.Why ctrl+shift+o does not organize imports automatically?

Upvotes: 0

Views: 433

Answers (1)

keaukraine
keaukraine

Reputation: 5364

You can use wildcard import like import static android.opengl.GLES20.* to import all stuff for sure but this is often considered to be a bad practice in Java - you can read more here Why is using a wild card with a Java import statement bad? and make your own mind. But I'd better suggest you to call GL commands with GLES20.glClearColor(...).

Upvotes: 1

Related Questions