在GL11 getFloatv功能问题(安卓)功能、问题、getFloatv

2023-09-13 02:20:10 作者:黑翼天使

我学习的Open GL ES和想获得更直观的界面比一个由谷歌在 TouchRotateActivity样本。 为了做到这一点,我想通过模型视图矩阵在previous状态,以加倍重视自己的模型变换矩阵。

I'm learning Open GL ES and would like to get a more intuitive interface with 3D objects than the one suggested by google in the TouchRotateActivity sample. In order to do that, I would like to multiply my Modelview matrix by the ModelView matrix in the previous state.

不过,我会遇到以下问题:getFloatv函数返回我的float数组0值,我不明白为什么(我的模型视图矩阵是不是空的:如果是这样,我不会让我的立方体在屏幕上)

But I encounter the following problem : getFloatv function returns 0 values in my float array, and I don't understand why (my ModelView matrix is not empty : if it was, I wouldn't get my cube on the screen).

有人能帮助我弄清楚的问题是什么?下面是变化code。

Could someone help me to figure out what the problem is? Here are the changes in the code .

private float[] previous;

public CubeRenderer() {
    mCube = new Cube();
    previous = new float[16];
}

public void onDrawFrame(GL10 gl) {
    GL11 gl11 = (GL11) gl;

    gl11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    gl11.glMatrixMode(GL11.GL_MODELVIEW);
    gl11.glLoadIdentity();
    gl11.glTranslatef(0, 0, -3.0f);
    gl11.glRotatef(mAngleX, 0, 1, 0);
    gl11.glRotatef(mAngleY, 1, 0, 0);

    gl11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    gl11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    /*if(!previous.equals(new float[16]))
        gl11.glMultMatrixf(previous, 0);*/
    gl11.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, previous, 0);

    Log.d("taille matrice",Integer.toString(previous.length));
    for(int i=0; i<previous.length;i++)
        Log.d(Integer.toString(i),Float.toString(previous[i]));

    mCube.draw(gl11);
}

感谢你在前进。

推荐答案

根据您的设​​备,你可能会使用PixelFlinger软件GL渲​​染器,不幸的是没有实现glGetFloat,至少为1.2版本。检查的logcat输出应揭示消息到这种效果,如果是这种情况。

Depending on your device you might be using the PixelFlinger software GL renderer, which unfortunately does not implement glGetFloat, at least as of version 1.2. Checking the logcat output should reveal messages to this effect if this is the case.

解决的办法是自己处理的矩阵,所以没有必要从OpenGL的检索它们摆在首位。 像这样。

The solution is to handle the matrices yourself so there's no need to retrieve them from OpenGL in the first place. Like so.