Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 701
Andrew Chen Avatar asked Jan 16 '23 17:01

Andrew Chen


1 Answers

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.

like image 139
Tim Avatar answered Jan 20 '23 02:01

Tim