Hash :
e49ab25c
Author :
Date :
2000-05-16T23:44:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#include "grobjs.h"
#include "grdevice.h"
#include <stdio.h>
#define GR_INIT_DEVICE_CHAIN ((grDeviceChain*)0)
#define GR_INIT_BUILD
#ifdef DEVICE_X11
#include "grx11.h"
#endif
#ifdef DEVICE_OS2_PM
#include "gros2pm.h"
#endif
#ifdef DEVICE_WIN32
#include "grwin32.h"
#endif
#ifdef macintosh
#include "grmac.h"
#endif
/**********************************************************************
*
* <Function>
* grInitDevices
*
* <Description>
* This function is in charge of initialising all system-specific
* devices. A device is responsible for creating and managing one
* or more "surfaces". A surface is either a window or a screen,
* depending on the system.
*
* <Return>
* a pointer to the first element of a device chain. The chain can
* be parsed to find the available devices on the current system
*
* <Note>
* If a device cannot be initialised correctly, it is not part of
* the device chain returned by this function. For example, if an
* X11 device was compiled in the library, it will be part of
* the returned device chain only if a connection to the display
* could be establisged
*
* If no driver could be initialised, this function returns NULL.
*
**********************************************************************/
extern
grDeviceChain* grInitDevices( void )
{
grDeviceChain* chain = GR_INIT_DEVICE_CHAIN;
grDeviceChain* cur = gr_device_chain;
while (chain)
{
/* initialize the device */
grDevice* device;
device = chain->device;
if ( device->init() == 0 &&
gr_num_devices < GR_MAX_DEVICES )
{
/* successful device initialisation - add it to our chain */
cur->next = 0;
cur->device = device;
cur->name = device->device_name;
if (cur > gr_device_chain)
cur[-1].next = cur;
cur++;
gr_num_devices++;
}
chain = chain->next;
}
return (gr_num_devices > 0 ? gr_device_chain : 0 );
}