Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES 2.0 (or Marmalade SDK), and effect similar to order of "glRotate()", "glTranslation()" in OpenGL ES 1.x

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?

like image 751
Sydnic Avatar asked Oct 06 '22 12:10

Sydnic


1 Answers

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

like image 101
Max Avatar answered Oct 22 '22 03:10

Max