Hi there,

I feel really stupid since I'm a beginner at OpenGL with drawing. Is there something that I'm missing in the code? The line doesn't show up on the screen. Thanks!

    glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 
    glBegin( GL_LINES );  
    glColor3f( 1.0f, 0.0f, 0.0f );  
    glVertex3f( 100.0f, 150.0f, 0.0f );  
    glVertex3f( 250.0f, 200.0f, 10.0f );

Recommended Answers

All 2 Replies

Where is your gluPerspective() call? Since I don't see where you are positioning the "camera" or "viewer" you might not have the correct far value.

I would try with negative Z values. Without rotations applied, the Z-axis points towards you (from the screen and out), with the zero being at the screen. This means that anything you draw in the positive-Z area is not going to appear on the screen (it is "behind" the camera). So, first thing, try making the Z coordinates in the negative.

Also, as sfuo said, very often when you try to draw stuff and nothing appears, it is usually because you set the perspective or model-view transformations wrong. Make sure that part is correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.