Android OpenGL ES基本用法(9),矩阵的旋转


目录


x轴向右
y轴向上
z轴向里
Android OpenGL ES基本用法(9),矩阵的旋转_第1张图片

矩阵的旋转
Matrix.rotateM(matrix, offset, a, x, y, z);

a:旋转角度
正数:逆时针旋转
负数:顺时针旋转

x、y、z:分别表示相应坐标轴 取值0,1类似于Boolen值,例如 x=1代表x轴旋转
    @Override
    public void onSurfaceChanged(int width, int height) {
     
        GLES20.glViewport(0, 0, width, height);
        Log.e(TAG, "onSurfaceChanged: width=" + width + "---height=" + height);
        fboRender.onChange(width, height);
        //横屏时候
        if (width > height) {
     
            Matrix.orthoM(matrix, 0, -width / ((height / 665f * 500f)), width / ((height / 665f * 500f)), -1f, 1f, -1f, 1f);
        } else {
     
            Matrix.orthoM(matrix, 0, -1, 1, -height / ((width / 500 * 655f)), height / ((width / 500f * 665f)), -1f, 1f);
        }
        Matrix.rotateM(matrix, 0, 180, 1, 0, 0);
//        Matrix.rotateM(matrix, 0, 45, 0, 0, 1);
    }

Android OpenGL ES基本用法(9),矩阵的旋转_第2张图片

    @Override
    public void onSurfaceChanged(int width, int height) {
     
        GLES20.glViewport(0, 0, width, height);
        Log.e(TAG, "onSurfaceChanged: width=" + width + "---height=" + height);
        fboRender.onChange(width, height);
        //横屏时候
        if (width > height) {
     
            Matrix.orthoM(matrix, 0, -width / ((height / 665f * 500f)), width / ((height / 665f * 500f)), -1f, 1f, -1f, 1f);
        } else {
     
            Matrix.orthoM(matrix, 0, -1, 1, -height / ((width / 500 * 655f)), height / ((width / 500f * 665f)), -1f, 1f);
        }
        //Matrix.rotateM(matrix, 0, 180, 1, 0, 0);
        Matrix.rotateM(matrix, 0, 45, 0, 0, 1);
    }

Android OpenGL ES基本用法(9),矩阵的旋转_第3张图片

你可能感兴趣的:(OpenGL)