Android: Deciding between SurfaceView and OpenGL (GLSurfaceView)

前端 未结 2 1801
盖世英雄少女心
盖世英雄少女心 2020-12-02 13:36

Is there a way to decide up front based on the expected complexity of a game/app in the planning phase whether to use regular Canvas drawing in a SurfaceView or to go with O

相关标签:
2条回答
  • 2020-12-02 14:23

    All I can say is that it depends on how many sprites you're gonna use. Chris Pruett from Google has also documented this part very well.

    Google I/O 2009 and Google I/O 2010.

    Below is a picture from one of his slides that are related to your topic: enter image description here

    With that knowledge, you should go with OpenGL using the draw_texture extension. Remember to query out the string and check if draw_texture is supported on the actual device.

    For further information that are related to game development in general, see this.

    0 讨论(0)
  • 2020-12-02 14:35

    SurfaceView

    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

    Source

    Difference between SurfaceView and GLSurfaceView in Android

    Android: Canvas vs OpenGL

    0 讨论(0)
提交回复
热议问题