Drawing lines in 3d world

I am trying to draw a simple 3 axis coordinate system using glfw lines, but i can’t see any line on the scene?

    // draw some lines
        glColor3f(1.0,0.0,0.0); // red x
        glBegin(GL_LINES);
        // x aix
     
        glVertex3f(-4.0, 0.0f, 0.0f);
        glVertex3f(4.0, 0.0f, 0.0f);
     
        glVertex3f(4.0, 0.0f, 0.0f);
        glVertex3f(3.0, 1.0f, 0.0f);
     
        glVertex3f(4.0, 0.0f, 0.0f);
        glVertex3f(3.0, -1.0f, 0.0f);
        glEnd();
     
        // y 
        glColor3f(0.0,1.0,0.0); // green y
        glBegin(GL_LINES);
        glVertex3f(0.0, -4.0f, 0.0f);
        glVertex3f(0.0, 4.0f, 0.0f);
     
        glVertex3f(0.0, 4.0f, 0.0f);
        glVertex3f(1.0, 3.0f, 0.0f);
     
        glVertex3f(0.0, 4.0f, 0.0f);
        glVertex3f(-1.0, 3.0f, 0.0f);
        glEnd();
     
        // z 
        glColor3f(0.0,0.0,1.0); // blue z
        glBegin(GL_LINES);
        glVertex3f(0.0, 0.0f ,-4.0f );
        glVertex3f(0.0, 0.0f ,4.0f );
     
     
        glVertex3f(0.0, 0.0f ,4.0f );
        glVertex3f(0.0, 1.0f ,3.0f );
     
        glVertex3f(0.0, 0.0f ,4.0f );
        glVertex3f(0.0, -1.0f ,3.0f );
        glEnd();

Hi @ALAXX,

welcome to the GLFW forums.

The question you’re asking is a general OpenGL one, rather than GLFW specific, so you may also be able to find help on other forums and sites.

It’s tricky to answer your questions in detail since there are other factors in getting something to render on screen, and you’ve only shown part of the program. Your problem might be to do with the matrix for example.

You’re using ‘legacy’ fixed function OpenGL, so you should take a look at the example boing.c. You could try modifying that example to add lines using similar coordinates to the ball.

If you’re still stuck after that, please post the entire code including matrix setup etc.

Cheers,

Doug.