0

我有以下代码在 3d 中创建一条线。

        GL.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT);

        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glLoadIdentity();

        GL.glBegin(GL.GL_LINES);
        GL.glColor(Color.Brown);
        GL.glVertex3f(0,0,0);
        GL.glVertex3f(100,0,0);
        GL.glEnd();

        GL.glBegin(GL.GL_LINES);
        GL.glColor(Color.Brown);
        GL.glVertex3f(0, 0, 0);
        GL.glVertex3f(0, 100, 0);
        GL.glEnd();

        GL.glBegin(GL.GL_LINES);
        GL.glColor(Color.Yellow);
        GL.glVertex3f(0, 0, 0);
        GL.glVertex3f(0, 0, 10);
        GL.glEnd();

        SwapBuffers();

但是当我运行程序时,我只看到第一个 2 的行...对于值为 100 的 x 和 y 轴。

什么不见​​了?

4

1 回答 1

2

Try to picture the line that goes from the origin (0,0,0) to (0,0,10).

It's always 0 in the x/y plane which means that if you're looking straight at it you won't see it if the position of your "camera" is perpendicular to the x/y plane.

If you change the "camera" position you should be able to see it.

于 2013-09-12T07:44:15.237 回答