glut multiple windows general

when i create 3 windows using glut like this

  for(int i=0;i<3;i++){
    glutInitWindowSize(300,300);
    glutInitWindowPosition(310*i,0);
    int x = glutCreateWindow("View");
    winid[i]=x;
  }

it will create the 3 windows… but if i try to select one, by doing

glutSetWindow(winid[0]);  

it will not work… the only window that can be accessed is the last one created. is there some sort of initialization so there can be more than one window?

Try setting each window after it’s created, then set your callbacks. Works fine for me, though I’ve not really played with it much.
http://www.opengl.org/resources/libraries/glut/spec3/spec3.html

im not sure i understand exactly what you mean… do you mean

  for(int i=0;i<3;i++){
    glutInitWindowSize(300,300);
    glutInitWindowPosition(310*i,0);
    int x = glutCreateWindow("View");
    winid[i]=x;
    glutSetWindow(winid[0]);  
  }

Pretty much, but you need to supply callbacks for each window you create.

for( int i = 0; i < 3; i++ )
{    
    glutInitWindowSize(300,300);    
    glutInitWindowPosition(310*i,0);    
    glutCreateWindow("View");    
	
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    // ...
}