Evan C
Evan C

Reputation: 141

What is the best method to draw 2D components under an OpenGL ES View in Android?

I'm looking to develop a game for Android using minimal 3D effects, but with mainly 2D graphics. I would prefer not to deal with OGLES Ortho projections and just stick with the simple 2D Canvas drawing provided by the Android SDK but everywhere I turn I only see solutions for using OGLES Ortho stuff.

Can anyone point me in the direction of a resource that would show me how to effectively render an OGLES view over a normal SurfaceView? Conceptually I think it would be something like having an Activity filled with a SurfaceView and an GLView on top of that, with the GLView's clear color being set to transparent. Am I at all on the right track with this? Is this approach even advisable or should I just bite the bullet and do everything with OpenGL?

Upvotes: 0

Views: 357

Answers (1)

Emmanuel
Emmanuel

Reputation: 13233

If you want to use OpenGL you should first start here. In short, Android lets you use GlSurfaceView in combination with a GlSurfaceView.Renderer to interact with the underlying, native OpenGL.

If you want a more "guided" approach, this is the book I am reading now.

Once you get familiar with OpenGL, you might want to use an engine like libgdx. After playing with it for a while you mind find that you want a tool to create your world. You can use this Box2D editor.

RUBE is a Box2D editor (that uses the Box2D physics engine) that will output a JSON file that represents your world, so you will need a parser to convert the JSON file to Java so you can use it with the engine. Luckily there is this project you can use for that.

Upvotes: 3

Related Questions