/*
 * triangle.c -- A simple example of OpenGL and GLUT.
 */

#include <GL/glut.h>
#include <unistd.h>
#include <stdio.h>

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 */
  glBegin(GL_POLYGON);			/* draw filled triangle */
  glVertex2i(200,125);			/* specify each vertex of triangle */
  glVertex2i(100,375);
  glVertex2i(300,375);
  glEnd();				/* OpenGL draws the filled triangle */
  glFlush();				/* Complete any pending operations */
}



void idlefunc(void)
{
		  int cnt = 0 ; 
		  char a[100];
        if (cnt++<1) displayCB(); // Call displayCB the first time
		  scanf("%s",a);
		  printf("got the input %s\n",a);
}

void keyCB(unsigned char key, int x, int y)	/* called on key press */
{
  char c,a[100]; 
  if( key == 'q' ) exit(0); 

  printf("Hello\n");
  //while (c=getchar() != 'Q' ) putchar(c+1); 
 scanf("%s",a);
 printf("got the inp7t %s\n",a);
 
}


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("Triangle");	/* create window */

  /* from this point on the current window is win */

  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 */
  glutKeyboardFunc(keyCB);		/* set window's key callback */

  glutIdleFunc(idlefunc);
  glutMainLoop();			/* start processing events... */

  /* execution never reaches this point */

  return 0;
}



