在GL11 getFloatv功能问题(安卓) [英] Problem with getFloatv function in GL11 (Android)

查看:278
本文介绍了在GL11 getFloatv功能问题(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习的Open GL ES和想获得更直观的界面比一个由谷歌在<建议的3D对象href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.html"相对=nofollow> 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的检索它们摆在首位。 <一href="http://$c$c.google.com/p/rugl/source/browse/trunk/droid/DroidRUGL/src/com/ryanm/droid/rugl/gl/GLU.java"相对=nofollow>像这样。

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

这篇关于在GL11 getFloatv功能问题(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆