다음을 통해 공유


GLSurfaceView.IRenderer.OnSurfaceChanged(IGL10, Int32, Int32) Method

Definition

Called when the surface changed size.

[Android.Runtime.Register("onSurfaceChanged", "(Ljavax/microedition/khronos/opengles/GL10;II)V", "GetOnSurfaceChanged_Ljavax_microedition_khronos_opengles_GL10_IIHandler:Android.Opengl.GLSurfaceView/IRendererInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void OnSurfaceChanged (Javax.Microedition.Khronos.Opengles.IGL10? gl, int width, int height);
[<Android.Runtime.Register("onSurfaceChanged", "(Ljavax/microedition/khronos/opengles/GL10;II)V", "GetOnSurfaceChanged_Ljavax_microedition_khronos_opengles_GL10_IIHandler:Android.Opengl.GLSurfaceView/IRendererInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member OnSurfaceChanged : Javax.Microedition.Khronos.Opengles.IGL10 * int * int -> unit

Parameters

gl
IGL10

the GL interface. Use instanceof to test if the interface supports GL11 or higher interfaces.

width
Int32

width

height
Int32

height

Attributes

Remarks

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);
            }

Java documentation for android.opengl.GLSurfaceView.Renderer.onSurfaceChanged(javax.microedition.khronos.opengles.GL10, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to