Andrew Chen
Andrew Chen

Reputation: 373

what is the purpose of onSurfaceChanged?

I don't exactly understand what the purpose of this method is. In the android documentation, they say that this is when the size of the screen is changed. Does this mean the size of the viewport, or what exactly does it mean? What opengl calls should I make in the method.

Upvotes: 4

Views: 6922

Answers (1)

Tim
Tim

Reputation: 35933

The method is called when the size of the viewport is changed or first created. This function is the first place where you will know exactly how many pixels your GlSurfaceView occupies.

In this method it would be appropriate to set the viewport, and perhaps to setup the projection matrix.

For example if the screen rotates from vertical to horizontal, the size of the viewport may change, so you should reset your viewport and projection matrices.

Upvotes: 9

Related Questions