Android: Deciding between SurfaceView and OpenGL (GLSurfaceView)
有没有办法在规划阶段根据游戏/应用程序的预期复杂性预先决定是在 SurfaceView 中使用常规 Canvas 绘图还是使用 OpenGL?
我一直在玩画布,只需要 2D 运动,在一部相当新的手机上,我获得了相当不错的性能,一堆原始对象和一些位图在屏幕上运行背景。
公平地说,如果我要绘制背景图像并增加在其上移动和绘制的对象的数量,我应该直接使用 OpenGL 吗?
我只能说这取决于你要使用多少sprite。来自 Google 的 Chris Pruett 也很好地记录了这一部分。
Google I/O 2009 和 Google I/O 2010。
下面是他的一张幻灯片中与您的主题相关的图片:
有了这些知识,您应该使用
有关一般游戏开发的更多信息,请参阅此。
表面视图
A GLSurfaceView is a SurfaceView that you can render into with OpenGL.
Choosing between them is simple:If you’re familiar with OpenGL and need what it provides, use a
GLSurfaceView. Otherwise, use a SurfaceView. OpenGL is low-level. If
you’re not already familiar with it, it’s an undertaking to learn. If
you only need 2D drawing, SurfaceView uses the high-level, reasonably
high-performance Canvas. It’s very easy to work with.Unless you have a strong reason to use a GLSurfaceView, you should use
a regular SurfaceView. I would suggest that if you don’t already know
that you need GL, then you probably don’t.
OpenGL
OpenGL would be able to handle the rotations and scaling easily.
Honestly, you would probably need to learn a lot of OpenGL to do this,
specifically related to the topics of:Geometry Lighting (or just disabling it) Picking (selecting geometry
to draw on it) Pixel Maps Texture Mapping Mipmapping Also, learning
OpenGL for this might be overkill, and you would have to be pretty
good at it to make it efficient.Instead, I would recommend using the graphic components of a game
library built on top of openGL, such as:Cocos2d
libgdx
Any of the engines listed here
来源
Android中SurfaceView和GLSurfaceView的区别
Android:画布与 OpenGL
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268968.html