This will never produce any output:
for(int i=0; i<points; i++)
{
glBegin(GL_LINES);
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3d(vList[i][0],vList[i][1],vList[i][2]);
glEnd();
}
GL_LINES requires two vertices per line, and you're only providing one between your glBegin
and glEnd
calls.
glBegin
and glEnd
should bookend particular pieces of geometry, not individual vertices.
However, simply moving the calls out of the for loop won't fix your problem:
glBegin(GL_LINES);
for(int i=0; i<points; i++)
{
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3d(vList[i][0],vList[i][1],vList[i][2]);
}
glEnd();
This would almost produce what you want, but will actually show every OTHER line, because it's treating each pair you send in as one line. So it will draw a line between point 1 and 2, and then between 3 and 4. This is because GL_LINES means "interpret each pair I send in as a completely new line, unrelated to the previous vertices.
What you really want is this:
glBegin(GL_LINE_STRIP);
for(int i=0; i<points; i++)
{
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3d(vList[i][0],vList[i][1],vList[i][2]);
}
glEnd();
Using GL_LINE_STRIP
instructs OpenGL that it should take the first two vertices and draw a line, and then for each new vertex, draw another line from the end of the last line.
Caveat
All this assumes your file is actually designed to produce lines like this. Most 3D file formats include both vertices and indices. The vertices tell you the 3D positions, but the indices tell you which points should be connected to which. However, since this looks like a sort of homework assignment, I'm going to assume that the file is as described, a simple list of X-Y-Z coordinates that should be connected in sequence.