opengl es的render的研究

本文深入探讨了在使用OpenGL ES进行绘图时,GL对象的生命周期特性及其与SurfaceView交互的过程。通过日志分析,揭示了GL对象在onDrawFrame函数执行期间始终保持同一实例的现象,并阐述了在界面布局变化时,Renderer如何响应onSurfaceChanged事件而onSurfaceCreated事件不触发的机制。进一步,文章还解析了SurfaceView在屏幕状态改变时执行特定生命周期回调的方法,提供了对于理解OpenGL ES与Android平台集成关键细节的重要见解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在研究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会先后被执行。

转载于:https://my.oschina.net/u/2291753/blog/378354

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值