0

I have the following code to create a line in 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();

But when i run the program I only see the lines for the 1st 2... for the x and y axis whose value is 100.

What is missing?

genpfault
  • 51,148
  • 11
  • 85
  • 139
RJ Uy
  • 377
  • 3
  • 10
  • 20

1 Answers1

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.

Simon
  • 6,293
  • 2
  • 28
  • 34