Clearing the Screen - garsue/libgdx GitHub Wiki

To clear the screen in Libgdx is not unlike clearing the screen in a regular OpenGL application. The only difference is in how one accesses the OpenGL context.

The following example accesses the context in an OpenGL ES2 application to clear the frame and depth buffers, setting the color buffer to a solid red color:

@Override
public void render() {

  Gdx.graphics.getGL20().glClearColor( 1, 0, 0, 1 );
  Gdx.graphics.getGL20().glClear( GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT );

  // scene render code...
}

Simply set the desired clear color and then call glClear() with the desired buffers to clear. You are then free to render a fresh frame with new scene graphics.

⚠️ **GitHub.com Fallback** ⚠️