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.
the code I have been working with is given below. Thank you
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
#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 < numPoint; i++)
 {
  glVertex2i(pointValx[i], pointValx[i]);
  printf("i >> %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 >> \n");
scanf("%d",&numPoint); //comment this line for Line
pointValx = (int*)malloc(numPoint * sizeof(int));
pointValy = (int*)malloc(numPoint * sizeof(int));
printf("numPoint >> %d\n",numPoint);
for(int i = 0; i < numPoint;)
{
    int x,y;
    printf("Input for X >> %d\n", i);
    scanf("%d",&x);
    printf("numPoint >> %d\n",numPoint);
    if(x >= 0 && x <= 400)
    {
        printf("Input for Y >> %d\n", i);
        scanf("%d",&y);
        if(y >= 0 && y <= 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(&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;
}
 
    