Convert An Android.graphics.matrix To A Gl Mat4?
I have a somewhat different issue than How to convert a 3x3 rotation matrix into 4x4 matrix?: I'm writing 2D OpenGL code that manipulates textures on a flat (z always equals 0) geo
Solution 1:
If you only do affine transformations, it will work that way. In that case, a31 and a32 can always be zero and a33 should be one anyways. You can get away with a 2x3 matrix in these situations, and with modern shader-based GL, you could even directly work with that 3x3 or 2x3 matrix without any conversion.
Note that if you do projective transforms, extending the matrix to 4x4 will still work, but introduces distortions in the z dimension.
Solution 2:
You should convert the translate X and Y values from Graphic coordinate system to a OpenGL coordinate system.
Here is a working example:
You can also check this question which is practically the same, but with explanation: OpenGL ES how to apply transformations from android.graphics.Matrix
Post a Comment for "Convert An Android.graphics.matrix To A Gl Mat4?"