Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android opengl-es-2.0 - rotateM explanation

I'm beginning with android opengl es 2.0 and I'm trying to get a grasp of the concepts. I've written the function below to rotate a rectangle. I've succeeded in making some rotations by playing with the values in the method rotateM. However I don't succeed in making some concrete rotations of my rectangle, for example rotate 2D 45 degrees to the right.

Basically I'm staring at the android reference which states the following;

rotateM(float[] m, int mOffset, float a, float x, float y, float z) Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z).

Now I understand that we provide a modelMatrix, an offset in this matrix and the angle rotation, but why do we have to provide the xyz - axis components, what do these values really do?

Hopefully somebody can give me a clear explanation regarding the method rotateM, thanks in advance!

private void positionRectangleInScene() {
    setIdentityM(modelMatrix, 0);

    rotateM(
        modelMatrix, // m        : source matrix
        0,           // mOffset  : index into m where the matrix starts
        0f,          // a        : angle ato rotate in degrees
        1f,          // x        : x-axis component
        1f,          // y        : y-axis component
        1f);         // z        : z-axis component

    multiplyMM(
        modelViewProjectionMatrix, 0, 
        viewProjectionMatrix, 0,
        modelMatrix, 0);
}
like image 810
Gio Avatar asked Mar 01 '14 13:03

Gio


People also ask

What is OpenGL ES in Android?

OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing hardware. OpenGL ES is a flavor of the OpenGL specification intended for embedded devices.

How do I check my OpenGL version on Android?

How can I check the OpenGL version of my Android device? You can search the internet for information about the capabilities of the contained graphics adapter (search term: ModelOfYourDevice OpenGL).

Can I update OpenGL version Android?

You can't. The OpenGL version supported depends on the hardware capabilities of your GPU. Outdated GPUs such as the Adreno 200 and Mali-400 series do not support version 3.0.


1 Answers

The xyz values represent the axis of rotation. For example, rotation around the y-axis will be specified as (m,0,angle,0,1,0). What you have specified as (1,1,1) indicates you will rotate around all 3 axes, not a typical usage.

like image 122
Prabindh Avatar answered Oct 15 '22 20:10

Prabindh