onSurfaceChanged

Called when the surface changed size.

Called after the surface is created and whenever the OpenGL ES surface size changes.

Typically you will set your viewport here. If your camera is fixed then you could also set your projection matrix here:

void onSurfaceChanged(GL10 gl, int width, int height) 
{
    gl.glViewport(0, 0, width, height);
    // for a fixed camera, set the projection too
    float ratio = (float) width / height;
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
}

Parameters

height

width

abstract fun onSurfaceChanged(width: Int, height: Int)