Hello, I need a bit of healp here. I recently been given some code and struggling to understand what this code below does I know that the vertices of the program is stored in the txt file but that’s al. I know there’s some form of interaction with it here but thats all i can get from this
ifstream infile("vertices.txt");
for (int i = 0; i < 5; i++){
infile >> vertices[i][0];
infile >> vertices[i][1];
cout << vertices[i][0] << " " << vertices[i][1] << endl;
All this code fragment does is read numbers from an input file, store them in an array named “vertices”, and print them on standard output. I suspect that something later in the code will use the values in the “vertices” array, but that’s not in the part you copied.
Oh yeah so obvious -.- Thank you so much.
void init()
{
cal_vertices();
read_vertices();
glNewList(listname, GL_COMPILE);
glBegin(GL_LINE_LOOP);
for(int i = 0; i < 5; i++){
glVertex3f(vertices[i][0], vertices[i][1], 0.0);
}
so this call vertices and read creates a gl list and then what?
Right, this code creates an OpenGL display list. You’ll probably find a glCallList() call somewhere else in the code. That will be where the rendering happens.