The onSurfaceChanged Method

This method allows the application to deal with size changes in the screen size. This is common in the phone and tablet word as we rotate the device and change the screen orientation.

257     public void onSurfaceChanged(GL10 glUnused, int width, int height)
258     {
259         // Resize our drawing surface to the new height and width.
260         GLES20.glViewport(0, 0, width, height);
261     }

Notes

The arguments to glViewport are the pixel coordinates of the lower left corner of the drawing area, then the drawing area's width and height. This example stretches from the lower left corner of the screen and covers its full height and width.

Remember that the normalized device coordinates always put -1, -1 at the lower left corner of the viewport and 1,1 at the upper right.