I want to learn OpenGL ES directly since I’m targeting my development to android, however. I want to learn OpenGL ES in order to develop my 2D games. I chose it for performances purpose (since basic SurfaceView drawing isn’t that efficient when it comes to RT games).
My question is: where to start?
I’ve spent over a month browsing Google and reading/trying some tutorials/examples I’ve found anywhere but to be honest, it didn’t help much and this is for two reasons:
- Almost all the articles/tutorials I’ve came across are 3D related (I only want to learn how to do my 2D Sprites drawing)
- There’s no base to start from since all the articles targets a specific things like: "How to draw a triangle (with vertices)", "How to create a Mesh"… etc.
I’ve tried to read some source code too (ex.: replica island) but the codes are too complicated and contains a lot of things that aren’t necessary; result: I get lost among 100 .java files with weird class names and stuff.
I guess there’s no course like the one I’m looking for, but I’ll be very glad if somebody could give me some guidelines and some links maybe to learn what I’m up to (only OpenGL ES 2D Sprites rendering! nothing 3D).
I was in a similar situation.
The way I started with openGL with start by looking at the very basic GLSurfaceView samples/demos.
Start, by setting up your app activity, and set up the basic canvas.
Take a loot at the replica island source code file: GameRenderer.java for how to setup your canvas with the proper GL flags for 2D (sprite) rendering.
You should really take a look at SpriteMethodTest by the same author of replica island: http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest
See this question where I posted my own code: Using OpenGL to replace Canvas – Android
After you have your canvas set up, you start by calling something like:
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
After that you’re ready to render a sprite.
First, you’ll need to load the sprite into a texture: http://qdevarena.blogspot.com/2009/02/how-to-load-texture-in-android-opengl.html
However, this is the tutorial that really helped me out with loading sprites:
http://tkcodesharing.blogspot.com/2008/05/working-with-textures-in-androids.html
This is how I do it, I have a class named Texture.java:
Then in my onDrawFrame() method I simply do:
That should get you going with drawing 2D sprites on an openGL canvas.
I’ve noticed that there is really no straightforward tutorial on this. Hopefully in the future I will post one in my dev blog: http://developingthedream.blogspot.com/