Example #1
0
/*!*****************************************************************************
 *******************************************************************************
 \note  createWindows
 \date  July 1998
 
 \remarks 
 
 initializes graphic windows
 
 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

 none
 

 ******************************************************************************/
int
createWindows(void)

{

  int i;
  int width=400, height=400;
  OpenGLWPtr w;
  
  /* get a window structure, initialized with default values */
  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;
  
  for (i=1; i<=N_CART; ++i) {
    w->eye[i] /= 1.3;
    w->eye0[i] = w->eye[i];
  }
  w->display = display;
  w->idle    = idle;
  w->width   = width;
  w->height  = height;
  if (!createWindow(w))
    return FALSE;

  return TRUE;

}
/*!*****************************************************************************
 *******************************************************************************
 \note  createWindows
 \date  July 1998
 
 \remarks 
 
 initializes graphic windows
 
 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

 none
 

 ******************************************************************************/
static int
createWindows(void)

{

  int i;
  OpenGLWPtr w;
  int width_eye=640/3;
  int height_eye=480/3;
  int height_main = 400;
  int width_main = 400;
  int hspace = 10;
  int vspace = 60;
  
  Display *disp;
  int  screen_num;
  int  display_width;
  int  display_height;

  char string[100];
  char xstring[100];

  double eye[N_CART+1];
  
  // connect to X server using the DISPLAY environment variable
  if ( (disp=XOpenDisplay(NULL)) == NULL ) {
    printf("Cannot connect to X servo %s\n",XDisplayName(NULL));
    exit(-1);
  }
  
  // get screen size from display structure macro 
  screen_num = DefaultScreen(disp);
  display_width = DisplayWidth(disp, screen_num);
  display_height = DisplayHeight(disp, screen_num);
  
  /* get a window structure, initialized with default values */
  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;

  w->display = display;
  w->idle    = idle;
  w->width   = width_main;
  w->height  = height_main;

  // check for user parameters
  if (read_parameter_pool_string(config_files[PARAMETERPOOL], 
				 "main_window_geometry", string))
    parseWindowSpecs(string, display_width,display_height,xstring, 
		     &(w->x), 
		     &(w->y), 
		     &(w->width),
		     &(w->height));

  if (read_parameter_pool_double_array(config_files[PARAMETERPOOL], 
				       "main_window_camera_pos", N_CART, eye))
    for (i=1; i<=N_CART; ++i)
      w->eye[i] = eye[i];
  
  // finally create the window
  for (i=1; i<=N_CART; ++i)
    w->eye0[i] = w->eye[i];

  if (!createWindow(w))
    return FALSE;

  /* get additional windows for the eyes */
  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;

  w->x      += width_main+hspace;
  w->fovea   = FOVEA_ANGLE;
  w->width   = width_eye;
  w->height  = height_eye;
  w->display = display;
  w->idle    = idle;
  sprintf(w->name,"LeftEyeFovea");
  if (!createWindow(w))
    return FALSE;

  toggleHideWindow(w);
  w_left_eye_fovea = w;

  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;

  w->x      += width_main+hspace+width_eye+hspace;
  w->fovea   = FOVEA_ANGLE;
  w->width   = width_eye;
  w->height  = height_eye;
  w->display = display;
  w->idle    = idle;
  sprintf(w->name,"RightEyeFovea");
  if (!createWindow(w))
    return FALSE;

  toggleHideWindow(w);
  w_right_eye_fovea = w;

  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;

  w->x      += width_main+hspace;
  w->y      += height_eye+vspace;
  w->fovea   = WIDE_ANGLE;
  w->width   = width_eye;
  w->height  = height_eye;
  w->display = display;
  w->idle    = idle;
  sprintf(w->name,"LeftEyeWide");
  if (!createWindow(w))
    return FALSE;
  
  toggleHideWindow(w);
  w_left_eye_wide = w;

  w=getOpenGLWindow();
  if (w==NULL)
    return FALSE;

  w->x      += width_main+hspace+width_eye+hspace;
  w->y      += height_eye+vspace;
  w->fovea   = WIDE_ANGLE;
  w->width   = width_eye;
  w->height  = height_eye;
  w->display = display;
  w->idle    = idle;
  sprintf(w->name,"RightEyeWide");
  if (!createWindow(w))
    return FALSE;

  toggleHideWindow(w);
  w_right_eye_wide = w;

  return TRUE;

}