Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Code explaination please

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2014
    Posts
    3

    Code explaination please

    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

    Code :
    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;

  2. #2
    Intern Contributor
    Join Date
    Mar 2014
    Location
    San Jose, CA
    Posts
    58
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2014
    Posts
    3
    Oh yeah so obvious -.- Thank you so much.
    Code :
    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?

  4. #4
    Intern Contributor
    Join Date
    Mar 2014
    Location
    San Jose, CA
    Posts
    58
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •