View Full Version : Code explaination please

04-25-2014, 09:03 AM
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;

04-25-2014, 01:05 PM
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.

04-25-2014, 01:37 PM
Oh yeah so obvious -.- Thank you so much.

void init()

glNewList(listname, GL_COMPILE);
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?

04-25-2014, 02:07 PM
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.