title: unable to draw Line Strip in a loop using GL_LINE_STRIP in openGL
body: <p>I am trying to draw some line strips using GL_LINE_STRIP in GLUT and OpenGL. I am taking the vertices input from two pointer (for x and y) and plotting them using a for loop. however, I am only getting final two lines as my output (from (0,0)[co-ordinate I have not mentioned in the pointer] to x0,y0),all the other vertices for the lineStrips are missing. Its in the display method.</p>
  
  <p>the code I have been working with is given below. Thank you</p>
  
  <pre><code>#ifdef __APPLE__
  #include &lt;GLUT/glut.h&gt;
  #else
  #include &lt;GL/glut.h&gt;
  #endif
  
  
  #include &lt;stdlib.h&gt;
  #include "stdio.h"
  
  int* pointValx;
  int* pointValy;
  int numPoint;
  
  
  void displayCB(void)        /* function called whenever redisplay needed */
  {
   glClear(GL_COLOR_BUFFER_BIT);      /* clear the display */
   glColor3f(1.0, 1.0, 1.0);      /* set current color to white */
   glPointSize(10.12);
   glBegin(GL_LINE_STRIP); //Begin triangle coordinates
  
   for(int i = 0; i &lt; numPoint; i++)
   {
    glVertex2i(pointValx[i], pointValx[i]);
    printf("i &gt;&gt; %d\n",i);
   }
   glEnd(); //End Co-ord
   glFlush();
   glutSwapBuffers();
   }
  
   int takeInput()
  {
  printf("Screen Size is 0 - 400 in X and 0 - 500 in Y\n");
  printf("Lab for Line and Point\n");
  printf("number of lines &gt;&gt; \n");
  scanf("%d",&amp;numPoint); //comment this line for Line
  
  pointValx = (int*)malloc(numPoint * sizeof(int));
  pointValy = (int*)malloc(numPoint * sizeof(int));
  
  printf("numPoint &gt;&gt; %d\n",numPoint);
  
  for(int i = 0; i &lt; numPoint;)
  {
      int x,y;
      printf("Input for X &gt;&gt; %d\n", i);
      scanf("%d",&amp;x);
      printf("numPoint &gt;&gt; %d\n",numPoint);
      if(x &gt;= 0 &amp;&amp; x &lt;= 400)
      {
          printf("Input for Y &gt;&gt; %d\n", i);
          scanf("%d",&amp;y);
          if(y &gt;= 0 &amp;&amp; y &lt;= 500)
          {
              pointValx[i] = x;
              pointValy[i] = y;
              i++;
          }
          else
          {
              printf("Y value crossed the limit\n");
          }
      }
      else
      {
         printf("X value crossed the limit\n");
      }
   }
  
  printf("End of Input file\n");
  return -1;
  }
  
  
  
  
  
  
  
  
  int main(int argc, char *argv[])
   {
  int win;
  
  glutInit(&amp;argc, argv);      /* initialize GLUT system */
  
  glutInitDisplayMode(GLUT_RGB);
  glutInitWindowSize(400,500);        /* width=400pixels height=500pixels */
  win = glutCreateWindow("GL_LINES and Points");  /* create window */
  
  /* from this point on the current window is win */
  takeInput();
  
  glClearColor(0.0,0.0,0.0,0.0);  /* set background to black */
  gluOrtho2D(0,400,0,500);        /* how object is mapped to window */
  glutDisplayFunc(displayCB);     /* set window's display callback */
  
  glutMainLoop();         /* start processing events... */
  
  /* execution never reaches this point */
  
  free(pointValx);
  free(pointValy);
  
  return 0;
  }
  </code></pre>