在研究Renderer的onDrawFrame函数时,好奇参数GL10类型的gl对象是不是在每次onDrawFrame被执行时都是一个。于是在函数中打日志Log.i(TAG, "[surface_drawed][gl:"+gl+"]");,查看logcat时,发现每次日志都是[surface_drawed][gl:com.google.android.gles_jni.GLImpl@421cc310]。所以断定gl对象每次都是一个。
02-13 11:54:02.823 3522-3538/com.sunhang.opengl I/SimpleRender﹕ [surface_drawed][gl:com.google.android.gles_jni.GLImpl@421cc310]
02-13 11:54:02.839 3522-3538/com.sunhang.opengl I/SimpleRender﹕ [surface_drawed][gl:com.google.android.gles_jni.GLImpl@421cc310]
02-13 11:54:02.856 3522-3538/com.sunhang.opengl I/SimpleRender﹕ [surface_drawed][gl:com.google.android.gles_jni.GLImpl@421cc310]
02-13 11:54:02.872 3522-3538/com.sunhang.opengl I/SimpleRender﹕ [surface_drawed]
我在界面中改变一下GLSurfaceView的布局,Renderer会执行onSurfaceChanged,但是不会执行onSurfaceCreated.
02-13 12:38:30.283 6889-6920/com.sunhang.opengl I/SimpleRender﹕ surface created
02-13 12:38:30.283 6889-6920/com.sunhang.opengl I/SimpleRender﹕ surface changed
02-13 12:38:34.328 6889-6920/com.sunhang.opengl I/SimpleRender﹕ surface changed
在SurfaceView中添加了一个Renderer,研究一下它的onSurfaceCreated和onSurfaceChanged在什么情况下 执行。发现在屏幕关闭和开启后,onSurfaceCreated和onSurfaceChanged不会被执行,在屏幕翻转时,created和 changed会先后被执行。