what is the purpose of onSurfaceChanged?

一笑奈何 提交于 2019-12-10 18:44:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10523386/what-is-the-purpose-of-onsurfacechanged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!