OpenGl:GLSurfaceView.Renderer 还是 GLSurfaceView?
这两者之间有什么区别,以及哪个更好?
What are the differences between those two, and also, which is better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是两个不同的东西:GLSurfaceView 是一个用于绘制对象的视图,而 GLSurfaceView.Renderer 是一个接口,应重写其方法来绘制对象。你可以看看这个
These are two different things: GLSurfaceView is a View to draw your objects on, and GLSurfaceView.Renderer is an interface, whose methods should be overridden to draw your objects. You can a look at this set of tutorials to get started with OpenGL in Android. Good luck!
简短版本:
GLSurfaceView 拥有 GLSurfaceView.Render。
长版本:
GLSurfaceView 扩展了 SurfaceView,并另外拥有一个渲染线程和一个由客户端设置的渲染对象。渲染线程持续运行或按需运行,并委托渲染对象使用 OpenGL API 绘制帧。对于 SurfaceView 和 GLSurfaceView,渲染是在主线程之外的单独线程中执行的。不同之处在于 SurfaceView 的渲染线程是由客户端创建的,而 GLSurfaceView 的渲染线程是由系统创建的。更重要的是,GLSurfaceView将在内部处理主线程和渲染线程之间的同步。
http://pierrchen.blogspot.jp/2014/04/android -ui-internal-glsurfaceview.html
short version:
GLSurfaceView owns GLSurfaceView.Render.
long version:
GLSurfaceView extends SurfaceView and additionally owns a render thread and a render object set by the client. The render thread keeps running , continuously or on-demand, and delegates to the render object to draw frame using OpenGL API. For both SurfaceView and GLSurfaceView, rendering is performing in a separate thread other than main thread. The difference is with SurfaceView the rendering thread is created by client while with GLSurfaceView it is created by the system. What's more, GLSurfaceView will internally handle the synchronization between main thread and rendering thread.
http://pierrchen.blogspot.jp/2014/04/android-ui-internal-glsurfaceview.html