# Which one have to use Canvas or Open GL for 2D game in Android

I am compleatly new to android gaming.
I want to develop a 2D game with some physics in it.
I want to know which one i have to use Open GL or Canvas and the reason for selection
I want to include a physics engine i dont know anything about that too
It will be very help full if anyone can share any idea's and suggections.

• Forget about physics in this first game, and focus on OpenGL – Zhen Sep 30 '12 at 17:14

You may be confusing "Surface View" with drawing via Canvas.

OpenGL allows hardware rendering (makes use of the GPU), even of 2D sprites (which you render to a polygon). This also gives your sprites additional features, such as rotation, hardware scaling, or setting them up in a 3D "perspective" to do things with that (like fake parallax scrolling).

Basically if you want any of the following, you probably have to use OpenGL:

• Intensive computation - basically anything where you want as much CPU as possible, so you want to push as much to the GPU as possible. Simple physics won't count for this.
• LOTS of sprites - In the dozens or hundreds.
• LOTS of scaling or some rotating of sprites - It's (relatively) expensive to scale sprites onto the Canvas, and very expensive/troublesome to rotate sprites on your own.

Drawing bitmaps with the Canvas object is arguably much simpler than implementing OpenGL. However for anything intensive, you may find later the class won't cut it. Basically if you don't need to do any of the above, you should be able to get away with just using Canvas.

• You are right master I siad surface view instead of canvas I had a littile bit confusion on that,Will edit my post .Thank you for your Support – Renjith K N Sep 7 '12 at 4:04
• @Ren Glad to help. Let me know if I could narrow the information you're interested in. – TheMaster42 Sep 7 '12 at 4:59

It seems you are mixing things... On Android you have to use SurfaceView to display OpenGL.OpenGL is a library and SurfaceView is the viewable part of OpenGL.

OpenGL is not a physic engine as you think,you can't handle speed,acceleration, gravity etc..this is the job of library like andengine,box 2d and many others

I recommand you to read this: http://developer.android.com/guide/topics/graphics/opengl.html

• Hi Vince, Sorry I had a confusion with canvas and surface view I will edit my Post, Thanks for the reply and support – Renjith K N Sep 7 '12 at 4:05