1

GL 堆栈下溢发生在glPopMatrix();

我无法弄清楚我遇到的问题..但我只是猜测push & pop Matrix ...

我知道弹出没有任何内容的堆栈可能会发生'堆栈下溢......但我不认为我有这个问题..请给我一个答案!

gl.glMatrixMode(GL10.GL_MODELVIEW);
            gl.glLoadIdentity();
            gl.glPushMatrix();
                gl.glScalef(1f, 1f, 1f);
                gl.glTranslatef(0f, 0f, 0f);

                gl.glMatrixMode(GL10.GL_TEXTURE);
                gl.glLoadIdentity();
                gl.glTranslatef(0.0f, bgScroll1,0.0f);
                background.draw(gl);
            gl.glPopMatrix();  //stack underflow happens at this line
4

1 回答 1

2

The GL maintains a seprate matrix stack for each matrix type: GL_MODELVIEW, GL_PROJECTION, adn GL_TEXTURE. The push/pop matrix operations always work on the current matrix mode (as all matrix-related GL commands). So your code pushes on the modelview stack, and tries to pop from the texture matrix stack, which probably is empty.

You should set the matrix mode back to GL_MODELVIEW after you modified the texture matrix.

于 2014-08-23T12:52:31.237 回答