Tuesday, November 22, 2011

A weekend with Android GLES20

So I spent most of the weekend porting my android game code from GL10 to GLES20 it's quite the endeavor especially if you've never worked with opengl shaders or matrices. Moving away from the matrix stack was about the hardest part. The shaders were easy to get a handle on all except for the texture passing bit since you don't actually bind the texture to a specific sampler it's done indirectly through the use of numbered textures and order of sampler definitions in the fragment shader.

I've worked with shaders before in a similar way with XNA so some of the concepts were familiar to me. The new part for me was getting a basic post-processing bloom shader to work. I got it now but apparently there are some techniques I have to research before I use it efficiently. But about the one thing that opengl offers that Java2D is without is additive blending which is extremely useful for a lot of great effects, of course you can create your own custom composite in Java for doing additive blending though performance might be an issue there.

But some of the things I learned in getting this to work are as follows,
  • One you need to setIdentity before filling in the transforms
  • You can use the Matrix.translateM, Matrix.rotateM, and Matrix.scaleM in sequence
  • If you want to translate for example from the last position in the matrix you need to multiply the matrix by the new translation matrix (problems with order of operations)
  • A problem I am still having is that of textures still appearing mirror or flipped and other such non-sense due to orientation issues.
  • Oh and you have to manage your own matrix stack, if you want to change coordinate systems to use local coordinates for a particular object.
I'll post examples and more details after the holidays.

Aside from that just getting ready for Turkey Day. Hope everyone has a good and thankful Thanksgiving!

No comments:

Post a Comment