/******************************************************************************
  init.c

  This file contains all the initialization procedures to set up a window 
  for X.  The procedure in this file is called init().

  In this file, the display is opened, the screen id is determined, the number
  of colour planes the machine has is found and the initialization of the white
  and black pixels is found.

  SOURCE REFERENCES:
	Nye, A (1990)  The definitive guides to the X window system
		(Vol 2): Xlib Programming Manual for Version 11.  O'Reilly
		and Associates, Inc.: Sebastopol.
*******************************************************************************/

#include "mainheader.h"			/* include header file */

void init(myDisplay,myScreen,myDepth)
Display                 **myDisplay;             /* pointer to the display */
int                     *myScreen;               /* screen we are using */
int                     *myDepth;                /* colour plane depth */
{
/*----------------------------------------------------------------------------
 	MAKE CONNECTION WITH THE SERVER
  FOR MORE INFORMATION SEE:
	XOpenDisplay	p. 327 and man pages XOpenDisplay (3X11)
	XDisplayName	p. 140 and man pages XSetErrorHandler (3X11)
-----------------------------------------------------------------------------*/

	*myDisplay = XOpenDisplay ("");
	if (*myDisplay == NULL)
	{
		fprintf (stderr, 
			"ERROR: Could not open a connection to X on display %s\n",
		XDisplayName (NULL));
		exit (0);
	}

/*----------------------------------------------------------------------------
	INFORMATION ABOUT THE SCREEN
-----------------------------------------------------------------------------*/
	*myScreen = DefaultScreen (*myDisplay);

/*----------------------------------------------------------------------------
	FINDING THE NUMBER OF COLOUR PLANES
-----------------------------------------------------------------------------*/
	*myDepth = DefaultDepth (*myDisplay, *myScreen);
}

/*****************************************************************************
		End of file init.c
******************************************************************************/
