I am trying to add some basic HUD to my game, but when I try to change the perspective I can see the text(which I mentioned before as HUD), but on a black screen. What seems to be the problem?

        gl.glMatrixMode(GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glOrtho(0.0, 640, 480, 0.0, -1.0f, 1.0f);
        gl.glMatrixMode(GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        gl.glColor3f(1, 0, 0);
        gl.glRasterPos2f(5, 100);
        glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, Float.toString(serCar.pointP()));
        gl.glRasterPos2f(95, 100);
        glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, Float.toString(clCar.pointP()));

        gl.glPopAttrib();
        gl.glMatrixMode(GL_PROJECTION);
        gl.glPopMatrix();
        gl.glMatrixMode(GL_MODELVIEW);
有帮助吗?

解决方案

Just, don't call this:

gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top