Android: Deciding between SurfaceView and OpenGL (GLSurfaceView)

前端 未结 2 1811
盖世英雄少女心
盖世英雄少女心 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: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

提交回复
热议问题