/* window.C
 */

#include <iostream.h>
#include "window.h"


#define MAX_NUM_WINDOWS 20


static window * windows[ MAX_NUM_WINDOWS ];


void window::registerWindow( int windowId )

{
  if (windowId < 0 || windowId >= MAX_NUM_WINDOWS) {
    cerr << "New window has windowId " << windowId
	 << ", which is outside the allowed range 0.." << MAX_NUM_WINDOWS-1 << endl;
    abort();
  }
  windows[ windowId ] = this;
}


void GLUTdisplay() {
#ifdef GL  
  windows[ glutGetWindow() ]->display();
#endif
}

void GLUTidle() {
#ifdef GL  
  windows[ glutGetWindow() ]->idle();
#endif
}

void GLUTreshape( int x, int y ) {
#ifdef GL  
  windows[ glutGetWindow() ]->reshape( x, y );
#endif
}

void GLUTmouseAction( int button, int state, int x, int y ) {
#ifdef GL  
  windows[ glutGetWindow() ]->mouseAction( button, state, x, y );
#endif
}

void GLUTmouseMotion( int x, int y ) {
#ifdef GL  
  windows[ glutGetWindow() ]->mouseMotion( x, y );
#endif
}

void GLUTkeyAction( unsigned char c, int x, int y ) {
#ifdef GL  
  windows[ glutGetWindow() ]->keyAction( c, x, y );
#endif
}
