Thanks for the reply Pixel. I didn't take your route exactly but I followed your logic. I have two cubes and a line. The problem is the line is not touching both cubes!
void drawNodes() {
glColor3f(1.0f, 1.0f, 1.0f);
// Draw node
glTranslatef(0.0f ,0.75f, 0.0f);
glutSolidCube(1);
// Draw node2
glTranslatef(0.0f, 2.0f, 0.0f);
glutSolidCube(1);
glBegin(GL_LINES); //Begin drawing lines
// 2 end points on line
glVertex3f(0.0f, 0.75f, 0.0f);
glVertex3f(0.0f, 2.0f, 0.0f);
glEnd();
}
This is my draw function