Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

opengl es - Problem with getFloatv function in GL11 (Android)

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.

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).

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);
}

Thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't program in Java, so for all I know, your problem could be in the way the memory is being passed to glGetFloatv. In any case, I found this page floating around out there, maybe it will help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...