5

In OpenGL ES 1.x, one could do glTranslate first, and then glRotate, to modify where the center of rotation is located (i.e. rotate around given point). As far as I understand, in OpenGL ES 2.0 matrix computations are done on CPU side. I am using IwGeom (from Marmalade SDK) – a typical (probably) matrix package. From documentation:

Matrices in IwGeom are effectively in 4x3 format, comprising a 3x3 rotation, and a 3-component vector translation.

I find it hard to obtain the same effect using this method. The translation is always applied after the rotation. More, in Marmalade, one also sets Model matrix:

IwGxSetModelMatrix( &modelMatrix );

And, apparently, rotation and translation is also applied in one order: a) rotation, b) translation.

How to obtain the OpenGL ES 1.x effect?

Sydnic
  • 53
  • 3

1 Answers1

4

Marmalades IwGX wraps OpenGL and it is more similar to GLES 1.0 then GLES 2.0 as it does not requires shaders.

glTranslate and glRotate modifying view matrix.

You may replace with

CIwFMat viewMat1 = IwGxGetModelMatrix();
CIwFMat rot; rot.SetIdentity(); rot.SetRotZ(.....); // or other matrix rotation function
CIwFMat viewMat2 = viewMat1; 
viewMat2.PostMult(rot); // or viewMat2.PreMult(rot);
IwGxSetModelMatrix(viewMat2);
// Draw Something
IwGxSetModelMatrix(&viewMat1);

If you use GLES 2.0 then matrix might be computed in vertex shader as well. That might be faster then CPU. CPU with NEON instructions have similar performance on iPhone 4S

Max
  • 6,286
  • 5
  • 44
  • 86
  • 1
    Can I ask for clarification? How to include the translation? Or, in other words, how to rotate around point (x, y, z)? – Sydnic Dec 28 '12 at 20:49
  • 1
    Here is your formula: `V2 = V1 * R * T` I have not used IwGx for a while but I am almost sure that `M1 = M1 * M2` is `M1.PostMult(M2)` and `M1 = M2 * M1` is `M1.PreMult(M2)`. – Max Dec 28 '12 at 22:28