在研究Renderer的onDrawFrame函數時,好奇參數GL10類型的gl對象是否是在每次onDrawFrame被執行時都是一個。因而在函數中打日誌Log.i(TAG, "[surface_drawed][gl:"+gl+"]");,查看logcat時,發現每第二天志都是[surface_drawed][gl:com.google.android.gles_jni.GLImpl@421cc310]。因此判定gl對象每次都是一個。android
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 changedgoogle
在SurfaceView中添加了一個Renderer,研究一下它的onSurfaceCreated和onSurfaceChanged在什麼狀況下 執行。發如今屏幕關閉和開啓後,onSurfaceCreated和onSurfaceChanged不會被執行,在屏幕翻轉時,created和 changed會前後被執行。日誌