我正在用Jogl制作3D世界,我想添加2D Gui以便将相机传送到所选位置。
我尝试调用GlLoadIdentity重置翻译,然后我使用了Vertex2f,但未显示任何内容。 当我删除GLLoadIdentity时,在世界上漂浮着Gui。 我注意到这是因为最小距离应大于1。 还有另一种方法吗?
显示功能的一部分:
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
GL2 gl = drawable.getGL().getGL2();
gl.glRotatef(pitch, 0, 1, 0);
gl.glRotatef(yaw, (float)Math.cos(Math.toRadians(pitch)), 0, (float)Math.sin(Math.toRadians(pitch)));
gl.glTranslatef(x, y, z);
gl.glBegin(GL2.GL_QUADS);
gl.glColor3f(0.2f, 0.8f, 0.2f);
gl.glVertex3f(100, -10, 100);
gl.glVertex3f(100, -10, -100);
gl.glVertex3f(-100, -10, -100);
gl.glVertex3f(-100, -10, 100);
gl.glColor3f(0.0f, 0.0f, 0.0f);
gl.glVertex3f(100, -9.9f, 30);
gl.glVertex3f(100, -9.9f, -30);
gl.glVertex3f(-100, -9.9f, -30);
gl.glVertex3f(-100, -9.9f, 30);
gl.glEnd();
gl.flush();//<==This thing does nothing
gl.glLoadIdentity();//<== It make the gui invisible and the gui float
//in the world when deleted
gl.glColor3f(1f, 1f, 1f);
gl.glBegin(GL2.GL_QUADS);
gl.glVertex2f(0f, 0f);
gl.glVertex2f(0f, 1f);
gl.glVertex2f(1f, 1f);
gl.glVertex2f(1f, 0f);
gl.glEnd();
Gui是不可见的,但是当我删除glLoadIdentity()时,Gui漂浮在世界上