简体   繁体   中英

Can someone tell me why I get an OpenGL stack underflow?

I wrote this code:

   void drawWinningScreen(GL10 gl) {



        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();



        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        font.setTopColor(1, 1, 0);
        font.setBottomColor(1, 0, 0);
        font.spaceString("You win", 0f, 0f, .7f, .7f, -0.15f, gl);
        gl.glPopMatrix();

        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glPopMatrix();

        int error = gl.glGetError();

    }

I think it should work, but it seems to be causing a stack underflow somewhere.

I figured it out. It was because the method has the side effect of setting the matrix mode to GL_PROJECTION. Code after it was expecting the matrix mode to be GL_MODELVIEW.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM