Пример #1
0
static GDHandle click_in_device_area(
	GDSpecPtr device_spec,
	Rect *frame,
	Point mouse)
{
	Point offset;
	GDHandle device, intersected_device= (GDHandle) NULL;

	get_device_area_offset(frame, &offset);
	
	for (device= GetDeviceList(); device; device= GetNextDevice(device))
	{
		if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive))
		{
			GDSpec spec;
			Rect bounds;
			
			BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0);
			if (HasDepthGDSpec(&spec))
			{
				get_device_area_frame(device, &bounds, offset);
				if (PtInRect(mouse, &bounds))
				{
					intersected_device= device;
					break;
				}
			}
		}
	}
	
	return intersected_device;
}
Пример #2
0
/*!	\brief Pre-order traverses the trees spanned by the BDiskDevices and their
		   subobjects.

	The supplied visitor's Visit(BDiskDevice*) method is invoked for each
	disk device and Visit(BPartition*) for each (non-disk device) partition.
	If Visit() returns \c true, the iteration is terminated and this method
	returns \c true. If supplied, \a device is set to the concerned device
	and in \a partition the pointer to the partition object is returned.

	\param visitor The visitor.
	\param device Pointer to a pre-allocated BDiskDevice to be initialized
		   to the device at which the iteration was terminated.
		   May be \c NULL.
	\param partition Pointer to a pre-allocated BPartition pointer to be set
		   to the partition at which the iteration was terminated.
		   May be \c NULL.
	\return \c true, if the iteration was terminated, \c false otherwise.
*/
bool
BDiskDeviceRoster::VisitEachPartition(BDiskDeviceVisitor* visitor,
	BDiskDevice* device, BPartition** partition)
{
	bool terminatedEarly = false;
	if (visitor) {
		int32 oldCookie = fDeviceCookie;
		fDeviceCookie = 0;
		BDiskDevice deviceOnStack;
		BDiskDevice* useDevice = device ? device : &deviceOnStack;
		BPartition* foundPartition = NULL;
		while (GetNextDevice(useDevice) == B_OK) {
			foundPartition = useDevice->VisitEachDescendant(visitor);
			if (foundPartition) {
				terminatedEarly = true;
				break;
			}
		}
		fDeviceCookie = oldCookie;
		if (!terminatedEarly)
			useDevice->Unset();
		else if (device && partition)
			*partition = foundPartition;
	}
	return terminatedEarly;
}
Пример #3
0
HRESULT CGraphRender::InstallCapture(REFCLSID clsidDevClass, LPCWSTR lpszName)
{
	Stop();
	HRESULT hr = S_OK;
	
	// Capture
	
	CComPtr<IBaseFilter> pCapture;
	GetNextDevice( clsidDevClass, &pCapture );
	
	return InstallFilter( pCapture, lpszName );
}
Пример #4
0
/*!	\brief Iterates through the all devices.

	The supplied visitor's Visit(BDiskDevice*) is invoked for each device.
	If Visit() returns \c true, the iteration is terminated and this method
	returns \c true. If supplied, \a device is set to the concerned device.

	\param visitor The visitor.
	\param device Pointer to a pre-allocated BDiskDevice to be initialized
		   to the device at which the iteration was terminated.
		   May be \c NULL.
	\return \c true, if the iteration was terminated, \c false otherwise.
*/
bool
BDiskDeviceRoster::VisitEachDevice(BDiskDeviceVisitor* visitor,
	BDiskDevice* device)
{
	bool terminatedEarly = false;
	if (visitor) {
		int32 oldCookie = fDeviceCookie;
		fDeviceCookie = 0;
		BDiskDevice deviceOnStack;
		BDiskDevice* useDevice = device ? device : &deviceOnStack;
		while (!terminatedEarly && GetNextDevice(useDevice) == B_OK)
			terminatedEarly = visitor->Visit(useDevice);
		fDeviceCookie = oldCookie;
		if (!terminatedEarly)
			useDevice->Unset();
	}
	return terminatedEarly;
}
Пример #5
0
static void draw_device_area(
	GDSpecPtr device_spec,
	GDHandle selected_device,
	Rect *frame)
{
	Point offset;
	GDHandle device;

	get_device_area_offset(frame, &offset);
	
	EraseRect(frame);
	FrameRect(frame);
	
	for (device= GetDeviceList(); device; device= GetNextDevice(device))
	{
		if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive))
		{
			GDSpec spec;
			Rect bounds;
			
			BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0);
			
			get_device_area_frame(device, &bounds, offset);
			
			RGBForeColor(HasDepthGDSpec(&spec) ? &rgb_dark_gray : &rgb_white);
			PaintRect(&bounds);
			RGBForeColor(&rgb_black);
			
			if (device==selected_device) PenSize(2, 2);
			FrameRect(&bounds);
			PenSize(1, 1);
			
			if (device==GetMainDevice())
			{
				bounds.bottom= bounds.top + DEVICE_AREA_MENU_BAR_HEIGHT;
				EraseRect(&bounds);
				FrameRect(&bounds);
			}
		}
	}
	
	return;
}
Пример #6
0
// New doMyDeviceLoop, now works with multiple monitors
void doMyDeviceLoop()
{
	int				depth;
	Rect			gDeviceRect;
	Rect			intersectingRect;
	GDHandle		gDevice;
	//WindowRecord	*windowRec = (WindowRecord *)gWindow;
	WindowPtr		windowRec = gWindow;
	Rect			windowRect; //= (**windowRec->contRgn).rgnBBox;
	RgnHandle		rgnHandle = NewRgn();
	
	GetWindowRegion(windowRec, kWindowContentRgn, rgnHandle);
	GetRegionBounds(rgnHandle, &windowRect);

	// Get the handle to the first device in the list. 
	gDevice = GetDeviceList();

	// Loop through all the devices in the list. 
	while (gDevice != nil)
	{
		// Get the device's gdRect  */
		gDeviceRect = (**gDevice).gdRect;
		depth = (**(**gDevice).gdPMap).pixelSize;

		// Check if the app's window rect intersects the device's, and if it 
		// does, set the clip region's rect to the intersection, then DRAW! 
		if (SectRect( &windowRect, &gDeviceRect, &intersectingRect ))
		{
			// The intersectingRect is in global coords. Convert to local 
			GlobalToLocal((Point *)&intersectingRect.top);
			GlobalToLocal((Point *)&intersectingRect.bottom);

			ClipRect( &intersectingRect );
			doDraw( depth, &intersectingRect );
		}

		// Get the next device in the list. 
		gDevice = GetNextDevice( gDevice );
	}
	
	DisposeRgn(rgnHandle);
}
Пример #7
0
Boolean CanUserPickMonitor (void)
{
	GDHandle dev = GetDeviceList();
	OSErr err = noErr;
	int numMonitors;
	
	// build the list of monitors
	numMonitors = 0;
	while (dev && numMonitors < kMaxMonitors)
	{
		if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive))
		{
			numMonitors++;
		}
		dev = GetNextDevice(dev);
	}

	if (numMonitors > 1) return true;
	else return false;
}
Пример #8
0
int printRendererInfo(void)
{
	GLenum   err;
	GDHandle device;
	GLuint   dnum = 0;
	
	device = GetDeviceList();
	while(device)
	{
		DPRINTF(3,(fp,"\nDevice : %d\n", dnum));
		CheckGetRendererInfo(device);
		device = GetNextDevice(device);
		dnum++;
	}
		
	err = aglGetError();
	if(err != AGL_NO_ERROR) DPRINTF(3,(fp,"aglGetError - %s\n", aglErrorString(err)));

   return 1;
}
Пример #9
0
BOOL AFXAPI AfxCheckMonochrome(const RECT* pRect)
{
	long versionQD;
	if (Gestalt(gestaltQuickdrawVersion, &versionQD) != noErr ||
			versionQD < gestalt8BitQD)
		return TRUE;

	// We draw all toolbars in monochrome if the main monitor is monochrome
	// because the main monitor is what determines the button face color
	// and button shadow color, and if those aren't grays, we won't get
	// reasonable output no matter how deep a monitor we're drawing on.
	if (GetSysColor(COLOR_BTNFACE) == RGB(255, 255, 255))
		return TRUE;

	Rect rectMacClient;
	rectMacClient.top = (short)pRect->top;
	rectMacClient.left = (short)pRect->left;
	rectMacClient.bottom = (short)pRect->bottom;
	rectMacClient.right = (short)pRect->right;

	for (GDHandle hgd = GetDeviceList(); hgd != NULL; hgd = GetNextDevice(hgd))
	{
		if (!TestDeviceAttribute(hgd, screenDevice) ||
				!TestDeviceAttribute(hgd, screenActive))
			continue;

		// ignore devices that the toolbar isn't drawn on
		Rect rect;
		if (!SectRect(&rectMacClient, &(*hgd)->gdRect, &rect))
			continue;

		// we require 2-bit grayscale or 4-bit color to draw in color
		int pixelSize = (*(*hgd)->gdPMap)->pixelSize;
		if (pixelSize == 1 || (pixelSize == 2 &&
				TestDeviceAttribute(hgd, gdDevType)))
			return TRUE;
	}

	return FALSE;
}
Пример #10
0
void myHideMenuBar(
	GDHandle ignoredDev)
{
	RgnHandle gray,rect;
	GDHandle dev;
	(void)ignoredDev;

	if (savedgray)
		return;
	gray=GetGrayRgn();
	savedgray=NewRgn();
	rect=NewRgn();
	CopyRgn(gray,savedgray);
	for (dev=GetDeviceList(); dev; dev=GetNextDevice(dev)) {
		if (!TestDeviceAttribute(dev,screenDevice)
				|| !TestDeviceAttribute(dev,screenActive))
			continue;
		RectRgn(rect,&(*dev)->gdRect);
		UnionRgn(gray,rect,gray);
	}
	DisposeRgn(rect);
	savedmbh=LMGetMBarHeight();
	LMSetMBarHeight(0);
}
Пример #11
0
GDHandle AFXAPI _AfxFindDevice(int x, int y)
{
	long lResult;
	Point pt;
	GDHandle hgd;

	if (Gestalt(gestaltQuickdrawVersion, &lResult) != noErr ||
			lResult < gestalt8BitQD)
		return NULL;

	pt.h = (short) x;
	pt.v = (short) y;

	hgd = GetDeviceList();
	while (hgd != NULL)
	{
		if (MacPtInRect(pt, &(*hgd)->gdRect))
			return hgd;

		hgd = GetNextDevice(hgd);
	}

	return NULL;
}
Пример #12
0
void slowPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE + 8 ];
	ProcessSerialNumber psn;
	GDHandle deviceHandle;
	GrafPtr currPort;
	QElemPtr queuePtr;
	QHdrPtr queueHdr;
	static BOOLEAN addedFixedItems = FALSE;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Walk through the list of graphics devices adding information about
	   a device (IM VI 21-21) */
	deviceHandle = GetDeviceList();
	while( deviceHandle != NULL )
		{
		GDHandle currentHandle = deviceHandle;
		GDPtr devicePtr;

		HLock( ( Handle ) currentHandle );
		devicePtr = *currentHandle;
		deviceHandle = devicePtr->gdNextGD;
		addRandomData( randomState, devicePtr, sizeof( GDevice ) );
		HUnlock( ( Handle ) currentHandle );
		}

	/* Walk through the list of processes adding information about each
	   process, including the name and serial number of the process, file and
	   resource information, memory usage information, the name of the
	   launching process, launch time, and accumulated CPU time (IM VI 29-17) */
	psn.highLongOfPSN = 0;
	psn.lowLongOfPSN = kNoProcess;
	while( !GetNextProcess( &psn ) )
		{
		ProcessInfoRec infoRec;
		GetProcessInformation( &psn, &infoRec );
		addRandomData( randomState, &infoRec, sizeof( ProcessInfoRec ) );
		}

	/* Get the command type, trap address, and parameters for all commands in
	   the file I/O queue.  The parameters are quite complex and are listed
	   on page 117 of IM IV, and include reference numbers, attributes, time
	   stamps, length and file allocation information, finder info, and large
	   amounts of other volume and filesystem-related data */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	if( ( queueHdr = GetFSQHdr() ) != NULL )
		queuePtr = queueHdr->qHead;
		while( queuePtr != NULL )
			{
			/* The queue entries are variant records of variable length so we
			   need to adjust the length parameter depending on the record
			   type */
			addRandomData( randomState, queuePtr, 32 ); /* dunno how big.. */
			queuePtr = queuePtr->qLink;
			}
#endif
	/* The following are fixed for the lifetime of the process so we only
	   add them once */
	if( !addedFixedItems )
		{
		Str255 appName, volName;
		GDHandle deviceHandle;
		Handle appHandle;
		DrvSts driveStatus;
		MachineLocation machineLocation;
		ProcessInfoRec processInfo;
		QHdrPtr vblQueue;
		SysEnvRec sysEnvirons;
		SysPPtr pramPtr;
		DefStartRec startupInfo;
		DefVideoRec videoInfo;
		DefOSRec osInfo;
		XPPParamBlock appleTalkParams;
		unsigned char *driverNames[] = {
			"\p.AIn", "\p.AOut", "\p.AppleCD", "\p.ATP", "\p.BIn", "\p.BOut", "\p.MPP",
			"\p.Print", "\p.Sony", "\p.Sound", "\p.XPP", NULL
			};
		SInt16 count, dummy, i, node, net, vRefNum, script;
		SInt32 lcount, volume;

		/* Get the current font family ID, node ID of the local AppleMumble
		   router, caret blink delay, CPU speed, double-click delay, sound
		   volume, application and system heap zone, the number of resource
		   types in the application, the number of sounds voices available,
		   the FRef of the current resource file, volume of the sysbeep,
		   primary line direction, computer SCSI disk mode ID, timeout before
		   the screen is dimmed and before the computer is put to sleep,
		   number of available threads in the thread pool, whether hard drive
		   spin-down is disabled, the handle to the i18n resources, timeout
		   time for the internal HDD, */
		addRandomValue( randomState, GetAppFont() );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		addRandomValue( randomState, GetBridgeAddress() );
#endif
		addRandomValue( randomState, GetCaretTime() );
/*		addRandomValue( randomState, GetCPUSpeed() ); */
		addRandomValue( randomState, GetDblTime() );
		GetSysBeepVolume( &volume );
		addRandomValue( randomState, volume );
		GetDefaultOutputVolume( &volume );
		addRandomValue( randomState, volume );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		addRandomValue( randomState, ApplicationZone() );
		addRandomValue( randomState, SystemZone() );
#endif
		addRandomValue( randomState, CountTypes() );
/*		CountVoices( &count ); ** seems to crash
		addRandomValue( randomState, count ); */
		addRandomValue( randomState, CurResFile() );
		GetSysBeepVolume( &lcount );
		addRandomValue( randomState, lcount );
		addRandomValue( randomState, GetSysDirection() );
/*		addRandomValue( randomState, GetSCSIDiskModeAddress() );
		addRandomValue( randomState, GetDimmingTimeout() );
		addRandomValue( randomState, GetSleepTimeout() ); */
		GetFreeThreadCount( kCooperativeThread, &count );
		addRandomValue( randomState, count );
/*		addRandomValue( randomState, IsSpindownDisabled() ); */
		addRandomValue( randomState, GetIntlResource( 0 ) );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		GetTimeout( &count );
		addRandomValue( randomState, count );
#endif

		/* Get the number of documents/files which were selected when the app
		   started and for each document get the vRefNum, name, type, and
		   version -- OBSOLETE
		CountAppFiles( &dummy, &count );
		addRandomValue( randomState, count );
		while( count > 0 )
			{
			AppFile theFile;
			GetAppFiles( count, &theFile );
			addRandomData( randomState, &theFile, sizeof( AppFile ) );
			count--;
			} */

		/* Get the app's name, resource file reference number, and handle to
		   the finder information -- OBSOLETE
		GetAppParams( appName, appHandle, &count );
		addRandomData( randomState, appName, sizeof( Str255 ) );
		addRandomValue( randomState, appHandle );
		addRandomValue( randomState, count ); */

		/* Get all sorts of statistics such as physical information, disk and
		   write-protect present status, error status, and handler queue
		   information, on floppy drives attached to the system.  Also get
		   the volume name, volume reference number and number of bytes free,
		   for the volume in the drive */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( !DriveStatus( 1, &driveStatus ) )
			addRandomData( randomState, &driveStatus, sizeof (DrvSts) );
#endif
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( !GetVInfo( 1, volName, &vRefNum, &lcount ) )
			{
			addRandomData( randomState, volName, sizeof( Str255 ) );
			addRandomValue( randomState, vRefNum );
			addRandomValue( randomState, lcount );
			}
#endif
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( !DriveStatus( 2, &driveStatus ) )
			addRandomData( randomState, &driveStatus, sizeof (DrvSts) );
#endif
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( !GetVInfo( 2, volName, &vRefNum, &lcount ) )
			{
			addRandomData( randomState, volName, sizeof( Str255 ) );
			addRandomValue( randomState, vRefNum );
			addRandomValue( randomState, lcount );
			}
#endif
		/* Get information on the head and tail of the vertical retrace
		   queue */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( ( vblQueue = GetVBLQHdr() ) != NULL )
			addRandomData( randomState, vblQueue, sizeof( QHdr ) );
#endif
		/* Get the parameter RAM settings */
		pramPtr = GetSysPPtr();
		addRandomData( randomState, pramPtr, sizeof( SysParmType ) );

		/* Get information about the machines geographic location */
		ReadLocation( &machineLocation );
		addRandomData( randomState, &machineLocation,
					   sizeof( MachineLocation ) );

		/* Get information on current graphics devices including device
		   information such as dimensions and cursor information, and a
		   number of handles to device-related data blocks and functions, and
		   information about the dimentions and contents of the devices pixel
		   image as well as the images resolution, storage format, depth, and
		   colour usage */
		deviceHandle = GetDeviceList();
		do
			{
			GDPtr gdPtr;

			addRandomValue( randomState, deviceHandle );
			HLock( ( Handle ) deviceHandle );
			gdPtr = ( GDPtr ) *deviceHandle;
			addRandomData( randomState, gdPtr, sizeof( GDevice ) );
			addRandomData( randomState, gdPtr->gdPMap, sizeof( PixMap ) );
			HUnlock( ( Handle ) deviceHandle );
			}
		while( ( deviceHandle = GetNextDevice( deviceHandle ) ) != NULL );

		/* Get the current system environment, including the machine and
		   system software type, the keyboard type, where there's a colour
		   display attached, the AppleTalk driver version, and the VRefNum of
		   the system folder */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		SysEnvirons( curSysEnvVers, &sysEnvirons );
		addRandomData( randomState, &sysEnvirons, sizeof( SysEnvRec ) );
#endif

		/* Get the AppleTalk node ID and network number for this machine */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( GetNodeAddress( &node, &net ) )
			{
			addRandomValue( randomState, node );
			addRandomValue( randomState, net );
			}
#endif
		/* Get information on each device connected to the ADB including the
		   device handler ID, the devices ADB address, and the address of the
		   devices handler and storage area */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		count = CountADBs();
		while( count-- > 0 )
			{
			ADBDataBlock adbInfo;

			GetIndADB( &adbInfo, count );
			addRandomData( randomState, &adbInfo, sizeof( ADBDataBlock ) );
			}
#endif
		/* Open the most common device types and get the general device
		   status information and (if possible) device-specific status.  The
		   general device information contains the device handle and flags,
		   I/O queue information, event information, and other driver-related
		   details */

/* Try something like this again.. and ur a dead man, Peter ;-)
      -xmath */

/*		for( count = 0; driverNames[ count ] != NULL; count++ )
			{
			AuxDCEHandle dceHandle;
			short driverRefNum;

			** Try and open the driver **
			if( OpenDriver( driverNames[ count ], &driverRefNum ) )
				continue;

			** Get a handle to the driver control information (this could
			   also be done with GetDCtlHandle()) **
			Status( driverRefNum, 1, &dceHandle );
			HLock( dceHandle );
			addRandomData( randomState, *dceHandle,
							 sizeof( AuxDCE ) );
			HUnlock( dceHandle );
			CloseDriver( driverRefNum );
			} */

		/* Get the name and volume reference number for the current volume */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		GetVol( volName, &vRefNum );
		addRandomData( randomState, volName, sizeof( Str255 ) );
		addRandomValue( randomState, vRefNum );
#endif
		/* Get the time information, attributes, directory information and
		   bitmap, volume allocation information, volume and drive
		   information, pointers to various pieces of volume-related
		   information, and details on path and directory caches, for each
		   volume */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( ( queueHdr = GetVCBQHdr() ) != NULL )
			queuePtr = queueHdr->qHead;
			while ( queuePtr != NULL )
				{
				addRandomData( randomState, queuePtr, sizeof( VCB ) );
				queuePtr = queuePtr->qLink;
				}
#endif

		/* Get the driver reference number, FS type, and media size for each
		   drive */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		if( ( queueHdr = GetDrvQHdr() ) != NULL )
			queuePtr = queueHdr->qHead;
			while ( queuePtr != NULL )
				{
				addRandomData( randomState, queuePtr, sizeof( DrvQEl ) );
				queuePtr = queuePtr->qLink;
				}
#endif
		/* Get global script manager variables and vectors, including the
		   globals changed count, font, script, and i18n flags, various
		   script types, and cache information */
		for( count = 0; count < 30; count++ )
			addRandomValue( randomState, GetScriptManagerVariable( count ) );

		/* Get the script code for the font script the i18n script, and for
		   each one add the changed count, font, script, i18n, and display
		   flags, resource ID's, and script file information */
		script = FontScript();
		addRandomValue( randomState, script );
		for( count = 0; count < 30; count++ )
			addRandomValue( randomState, GetScriptVariable( script, count ) );
		script = IntlScript();
		addRandomValue( randomState, script );
		for( count = 0; count < 30; count++ )
			addRandomValue( randomState, GetScriptVariable( script, count ) );

		/* Get the device ID, partition, slot number, resource ID, and driver
		   reference number for the default startup device */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		GetDefaultStartup( &startupInfo );
		addRandomData( randomState, &startupInfo, sizeof( DefStartRec ) );
#endif
		/* Get the slot number and resource ID for the default video device */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		GetVideoDefault( &videoInfo );
		addRandomData( randomState, &videoInfo, sizeof( DefVideoRec ) );
#endif
		/* Get the default OS type */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		GetOSDefault( &osInfo );
		addRandomData( randomState, &osInfo, sizeof( DefOSRec ) );
#endif
		/* Get the AppleTalk command block and data size and number of
		   sessions */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
		ASPGetParms( &appleTalkParams, FALSE );
		addRandomData( randomState, &appleTalkParams,
					   sizeof( XPPParamBlock ) );
#endif
		addedFixedItems = TRUE;
		}

	/* Flush any remaining data through */
	endRandomData( randomState, 100 );
	}
Пример #13
0
OSErr SetupPickMonitorPane(ControlRef inPane, DisplayIDType inDefaultMonitor)
{
	GDHandle dev = GetDeviceList();
	OSErr err = noErr;
	
	// make the default monitor the selected device
	if (inDefaultMonitor)
		DMGetGDeviceByDisplayID(inDefaultMonitor, &sSelectedDevice, true);
	else
		sSelectedDevice = GetMainDevice();

	// build the list of monitors
	sNumMonitors = 0;
	while (dev && sNumMonitors < kMaxMonitors)
	{
		if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive))
		{
			sMonitors[sNumMonitors].device = dev;
			sMonitors[sNumMonitors].origRect = (**dev).gdRect;
			sMonitors[sNumMonitors].isMain = (dev == GetMainDevice());
			sNumMonitors++;
		}
		dev = GetNextDevice(dev);
	}

	// calculate scaled rects
	if (sNumMonitors)
	{
		Rect origPaneRect, paneRect;
		Rect origGrayRect, grayRect, scaledGrayRect;
		float srcAspect, dstAspect, scale;
		int i;
		
		GetControlBounds(inPane, &origPaneRect);
		paneRect = origPaneRect;
		OffsetRect(&paneRect, -paneRect.left, -paneRect.top);
		
		GetRegionBounds(GetGrayRgn(), &origGrayRect);
		grayRect = origGrayRect;
		OffsetRect(&grayRect, -grayRect.left, -grayRect.top);
		
		srcAspect = (float)grayRect.right / (float)grayRect.bottom;
		dstAspect = (float)paneRect.right / (float)paneRect.bottom;
		
		scaledGrayRect = paneRect;
		
		if (srcAspect < dstAspect)
		{
			scaledGrayRect.right = (float)paneRect.bottom * srcAspect;
			scale = (float)scaledGrayRect.right / grayRect.right;
		}
		else
		{
			scaledGrayRect.bottom = (float)paneRect.right / srcAspect;
			scale = (float)scaledGrayRect.bottom / grayRect.bottom;
		}
		
		for (i = 0; i < sNumMonitors; i++)
		{
			Rect r = sMonitors[i].origRect;
			Rect r2 = r;
			
			// normalize rect and scale
			OffsetRect(&r, -r.left, -r.top);
			r.bottom = (float)r.bottom * scale;
			r.right = (float)r.right * scale;
			
			// offset rect wrt gray region
			OffsetRect(&r, (float)(r2.left - origGrayRect.left) * scale, 
							(float)(r2.top - origGrayRect.top) * scale);

			sMonitors[i].scaledRect = r;
		}
		
		// center scaledGrayRect in the pane
		OffsetRect(&scaledGrayRect, (paneRect.right - scaledGrayRect.right) / 2,
					(paneRect.bottom - scaledGrayRect.bottom) / 2);

		// offset monitors to match
		for (i = 0; i < sNumMonitors; i++)
			OffsetRect(&sMonitors[i].scaledRect, scaledGrayRect.left, scaledGrayRect.top);
	}
	else
		return paramErr;
		
	// setup the procs for the pick monitor user pane
	err = SetupUserPaneProcs(inPane, drawProc, hitTestProc, trackingProc);
	return err;
}
Пример #14
0
/*
Пример #15
0
static void ROM_HideMenuBar(_THIS)
{
#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
	RgnHandle		drawRgn = nil;
	RgnHandle		tempRgn = nil;
	RgnHandle		grayRgn = nil;
	WindowPtr		window = nil;
	GDHandle		gd = nil;
	GrafPtr			savePort;
	long			response;
	short			height;
	EventRecord		theEvent;

	height = GetMBarHeight();
	
	if ( height > 0 ) {
		tempRgn = NewRgn();
		drawRgn = NewRgn();
		gSaveGrayRgn = NewRgn();
		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
			goto CLEANUP;
		}
		grayRgn = GetGrayRgn(); /* No need to check for this */
	
		GetPort(&savePort);

		/* Hide the control strip if it's present, and record its 
		   previous position into the dirty region for redrawing. 
		   This isn't necessary, but may help catch stray bits. */
		CopyRgn(grayRgn, tempRgn);
		if (!Gestalt(gestaltControlStripAttr, &response) && 
			(response & (1L << gestaltControlStripExists))) {
			gSaveCSVis = SBIsControlStripVisible();
			if (gSaveCSVis)
				SBShowHideControlStrip(false);
		}
		DiffRgn(grayRgn, tempRgn, drawRgn);

		/* Save the gray region once the control strip is hidden*/
		CopyRgn(grayRgn, gSaveGrayRgn);

		/* Change the menu height in lowmem */
		gSaveMenuBar = height;
		LMSetMBarHeight(0);
		
		/* Walk the monitor rectangles, and combine any pieces that
		   aren't in GrayRgn: menubar, round corners, fake floaters. */
		for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) 
			{
			if (!TestDeviceAttribute(gd, screenDevice)) continue;
			if (!TestDeviceAttribute(gd, screenActive)) continue;

			RectRgn(tempRgn, &(*gd)->gdRect);	/* Get the whole screen */
			DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */
			UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */
			}
			
		/* Add the bits into the GrayRgn */
		UnionRgn(drawRgn, grayRgn, grayRgn);

		/* Modify the vis regions of exposed windows */
		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
		PaintBehind(window, drawRgn);
		CalcVisBehind(window, drawRgn);

		SetPort(savePort);
		
		/* Yield time so that floaters can catch up */
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		}

CLEANUP:

	if (tempRgn) DisposeRgn(tempRgn);
	if (drawRgn) DisposeRgn(drawRgn);
#endif /* !TARGET_API_MAC_CARBON */
}
Пример #16
0
uint4 MCScreenDC::getdisplays(MCDisplay const *& p_displays, bool p_effective)
{
	if (s_monitor_count == 0)
	{
		bool error = false;
	
		uint4 t_display_count;
		
		t_display_count = 0;
		for(GDHandle t_device = GetDeviceList(); t_device != NULL; t_device = GetNextDevice(t_device))
			if (TestDeviceAttribute(t_device, screenDevice) && TestDeviceAttribute(t_device, screenActive))
				t_display_count += 1;
			
		error = t_display_count == 0;
		
		MCDisplay *t_displays = NULL;
		if (!error)
			error = (t_displays = new MCDisplay[t_display_count]) == NULL;
			
		if (!error)
		{
			uint4 t_current_index = 1;
			for(GDHandle t_device = GetDeviceList(); t_device != NULL; t_device = GetNextDevice(t_device))
				if (TestDeviceAttribute(t_device, screenDevice) && TestDeviceAttribute(t_device, screenActive))
				{
					uint4 t_index;
					
					HLock((Handle)t_device);
					
					if (TestDeviceAttribute(t_device, mainScreen))
						t_index = 0;
					else
						t_index = t_current_index++;
						
					t_displays[t_index] . index = t_index;
						
					t_displays[t_index] . viewport . x = (*t_device) -> gdRect . left;
					t_displays[t_index] . viewport . y = (*t_device) -> gdRect . top;
					t_displays[t_index] . viewport . width = (*t_device) -> gdRect . right - (*t_device) -> gdRect . left;
					t_displays[t_index] . viewport . height = (*t_device) -> gdRect . bottom - (*t_device) -> gdRect . top;
				
					Rect t_workarea;
					GetAvailableWindowPositioningBounds(t_device, &t_workarea);
					t_displays[t_index] . workarea . x = t_workarea . left;
					t_displays[t_index] . workarea . y = t_workarea . top;
					t_displays[t_index] . workarea . width = t_workarea . right - t_workarea . left;
					t_displays[t_index] . workarea . height = t_workarea . bottom - t_workarea . top;
					
					HUnlock((Handle)t_device);
				}
		}
		
		if (error)
			delete[] t_displays;
		else
		{
			s_monitor_count = t_display_count;
			s_monitor_displays = t_displays;
		}
	}
	
	if (s_monitor_count == 0)
	{
		static MCDisplay t_display;
		Rect t_workarea;
		
		MCU_set_rect(t_display . viewport, 0, 0, getwidth(), getheight());
		GetAvailableWindowPositioningBounds(GetMainDevice(), &t_workarea);
		t_display . index = 0;
		t_display . workarea . x = t_workarea . left;
		t_display . workarea . y = t_workarea . top;
		t_display . workarea . width = t_workarea . right - t_workarea . left;
		t_display . workarea . height = t_workarea . bottom - t_workarea . top;
		p_displays = &t_display;
		
		return 1;
	}
	
	p_displays = s_monitor_displays;
	return s_monitor_count;
}
Пример #17
0
void CheckOpenGLCaps (CGDisplayCount maxDspys, 
                      GLCaps dCaps[], 
                      CGDisplayCount * dCnt)
{
  CGLContextObj curr_ctx = 0;
  CGDirectDisplayID dspys[32];
  CGDisplayErr err;
  unsigned short i;
  short size = sizeof (GLCaps);
  
  // no devices
  *dCnt = 0;
  
  if (maxDspys == 0) { // find number of displays
    *dCnt = 0;
    err = CGGetActiveDisplayList (32, dspys, dCnt);
    if (err) // err getting list
      *dCnt = 0; // 0 displays since can't correctly find any
    // zero list to ensure the routines are used correctly
    memset (dspys, 0, sizeof (CGDirectDisplayID) * *dCnt);
    return; // return dCnt
  }
  if (NULL == dCaps) return;

  err = CGGetActiveDisplayList(maxDspys, dspys, dCnt);
  if (err) return; // err getting list
  if (0 == *dCnt) return; // no displays
  
  memset (dCaps, 0, size * *dCnt); // zero memory
  
  for (i = 0; i < *dCnt; i++) {
    // get device ids
    dCaps[i].cgDisplayID = dspys[i];
    dCaps[i].cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(dspys[i]);
    
    { // get current geometry
      CGRect displayRect = CGDisplayBounds (dspys[i]);
      // get mode dictionary
      CFDictionaryRef dispMode = CGDisplayCurrentMode (dspys[i]); 
      dCaps[i].deviceWidth = (long) displayRect.size.width;   
      dCaps[i].deviceHeight = (long) displayRect.size.height;   
      dCaps[i].deviceOriginX = (long) displayRect.origin.x;   
      dCaps[i].deviceOriginY = (long) displayRect.origin.y;   
      dCaps[i].deviceDepth = (short) _getDictLong (dispMode,  
                                              kCGDisplayBitsPerPixel);    
      dCaps[i].deviceRefresh = (short) (_getDictDouble (dispMode,
                                        kCGDisplayRefreshRate) + 0.5); 
    }

    { // find gDevice device by bounds
      GDHandle hGD;
      for (hGD = GetDeviceList (); hGD; hGD = GetNextDevice (hGD))
      {
        if (!TestDeviceAttribute (hGD, screenDevice) ||
            !TestDeviceAttribute (hGD, screenActive))
          continue;
  
        // if postion and sizes match
        if (((*hGD)->gdRect.top == dCaps[i].deviceOriginY) &&
          ((*hGD)->gdRect.left == dCaps[i].deviceOriginX) &&
          (((*hGD)->gdRect.bottom - (*hGD)->gdRect.top) ==
                                                  dCaps[i].deviceHeight) &&
          (((*hGD)->gdRect.right - (*hGD)->gdRect.left) ==
                                                  dCaps[i].deviceWidth)) {
          dCaps[i].hGDevice = hGD;
          break;
        }
      }
      if (dCaps[i].hGDevice == NULL)
        return; // err
      if (noErr != DMGetDisplayIDByGDevice (dCaps[i].hGDevice,
                                            &dCaps[i].displayID, false))
        dCaps[i].displayID = 0; // err getting display ID
    }
    
    
    { // get renderer info based on gDevice
      CGLRendererInfoObj info;
      long j, numRenderers = 0, rv = 0;
      err = (CGLError)0;
      
      err = CGLQueryRendererInfo (dCaps[i].cglDisplayMask, 
                                  &info, 
                                  &numRenderers);
      if (0 == err) {
        CGLDescribeRenderer (info, 0, kCGLRPRendererCount, &numRenderers);
        for (j = 0; j < numRenderers; j++) {
          // find accelerated renderer (assume only one)
          CGLDescribeRenderer (info, j, kCGLRPAccelerated, &rv); 
          if (true == rv) { // if accelerated
            // what is the renderer ID
            CGLDescribeRenderer (info, j, kCGLRPRendererID,
                                 (long *)&dCaps[i].rendererID);
            // can we do full screen?
            CGLDescribeRenderer (info, j, kCGLRPFullScreen, &rv); 
            dCaps[i].fullScreenCapable = (bool) rv;
            // what is the VRAM?
            CGLDescribeRenderer (info, j, kCGLRPVideoMemory,
                                 &dCaps[i].deviceVRAM);
            // what is the current texture memory? 
            CGLDescribeRenderer (info, j, kCGLRPTextureMemory,
                                 &dCaps[i].deviceTextureRAM);
            break; // done
          }
        }
      }
      CGLDestroyRendererInfo (info);
    }

    { // build context and context specific info
      CGLPixelFormatAttribute attribs[] = { (CGLPixelFormatAttribute)kCGLPFADisplayMask,
                                            (CGLPixelFormatAttribute)dCaps[i].cglDisplayMask, 
                                            (CGLPixelFormatAttribute)NULL };
      CGLPixelFormatObj pixelFormat = NULL;
      long numPixelFormats = 0;
      CGLContextObj cglContext;
      
      curr_ctx = CGLGetCurrentContext (); // get current CGL context
      CGLChoosePixelFormat (attribs, &pixelFormat, &numPixelFormats);
      if (pixelFormat) {
        CGLCreateContext(pixelFormat, NULL, &cglContext);
        CGLDestroyPixelFormat (pixelFormat);
        CGLSetCurrentContext (cglContext);
        if (cglContext) {
          const GLubyte * strExt;
          const GLubyte * strRend;
          const GLubyte * strVers;
          const GLubyte * strVend;

          // get renderer strings
          strRend = glGetString (GL_RENDERER);
          strncpy (dCaps[i].strRendererName, (const char*)strRend, 255);
          strVend = glGetString (GL_VENDOR);
          strncpy (dCaps[i].strRendererVendor, (const char*)strVend, 255);
          strVers = glGetString (GL_VERSION);
          strncpy (dCaps[i].strRendererVersion, (const char*)strVers, 255);
          { // get BCD version
            short j = 0;
            short shiftVal = 8;
            while (((strVers[j] <= '9') && (strVers[j] >= '0')) ||
                                            (strVers[j] == '.')) { 
            // get only basic version info (until first non-digit or non-.)
              if ((strVers[j] <= '9') && (strVers[j] >= '0')) {
                dCaps[i].glVersion += (strVers[j] - '0') << shiftVal;
                shiftVal -= 4;
              }
              j++;
            }
          }
          strExt = glGetString (GL_EXTENSIONS);

          // get caps
          glGetIntegerv (GL_MAX_TEXTURE_UNITS, 
                         &dCaps[i].textureUnits);
          glGetIntegerv (GL_MAX_TEXTURE_SIZE,
                         &dCaps[i].maxTextureSize); 
          glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, 
                         &dCaps[i].max3DTextureSize);
          glGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE, 
                         &dCaps[i].maxCubeMapTextureSize);

          // get functionality info
          dCaps[i].fSpecularVector = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_specular_vector", strExt);
          dCaps[i].fTransformHint = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_transform_hint", strExt);
          dCaps[i].fPackedPixels = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_packed_pixels", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_packed_pixel", strExt)  || 
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fClientStorage = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_client_storage", strExt);
          dCaps[i].fYCbCr = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_ycbcr_422", strExt);
          dCaps[i].fTextureRange = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_texture_range", strExt);
          dCaps[i].fFence = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_fence", strExt);
          dCaps[i].fVAR = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_vertex_array_range", strExt);
          dCaps[i].fVAO = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_vertex_array_object", strExt);
          dCaps[i].fElementArray = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_element_array", strExt);
          dCaps[i].fVPEvals = 
            gluCheckExtension((const GLubyte*)"GL_APPLE_vertex_program_evaluators",strExt);
          dCaps[i].fFloatPixels = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_float_pixels", strExt);
          dCaps[i].fFlushRenderer = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_flush_render", strExt);
          dCaps[i].fPixelBuffer = 
            gluCheckExtension ((const GLubyte*)"GL_APPLE_pixel_buffer", strExt);
          dCaps[i].fImaging = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fTransposeMatrix = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_transpose_matrix", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fMultitexture = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_multitexture", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexEnvAdd = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_add", strExt) ||
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture_env_add", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexEnvCombine = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_combine", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexEnvDot3 = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_dot3", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexEnvCrossbar = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_crossbar", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fTexCubeMap = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_cube_map", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexCompress = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_compression", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fMultisample = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_multisample", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fTexBorderClamp = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_border_clamp", strExt) ||
            (dCaps[i].glVersion >= 0x0130);
          dCaps[i].fPointParam = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_point_parameters", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fVertexProg = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_vertex_program", strExt);
          dCaps[i].fFragmentProg = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_fragment_program", strExt);
          dCaps[i].fTexMirrorRepeat = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_texture_mirrored_repeat", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fDepthTex = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_depth_texture", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fShadow = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_shadow", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fShadowAmbient = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_shadow_ambient", strExt);
          dCaps[i].fVertexBlend = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_vertex_blend", strExt);
          dCaps[i].fWindowPos = 
            gluCheckExtension ((const GLubyte*)"GL_ARB_window_pos", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fTex3D = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture3D", strExt) ||
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fClipVolHint = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_clip_volume_hint", strExt);
          dCaps[i].fRescaleNorm = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_rescale_normal", strExt) ||
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fBlendColor = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_blend_color", strExt) ||
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fBlendMinMax = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_blend_minmax", strExt) ||
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fBlendSub = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_blend_subtract", strExt) ||
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fCVA = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_compiled_vertex_array", strExt);
          dCaps[i].fTexLODBias = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture_lod_bias", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fABGR = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_abgr", strExt);
          dCaps[i].fBGRA = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_bgra", strExt) ||
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fTexFilterAniso = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture_filter_anisotropic",strExt);
          dCaps[i].fPaletteTex = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_paletted_texture", strExt);
          dCaps[i].fShareTexPalette = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_shared_texture_palette", strExt);
          dCaps[i].fSecColor = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_secondary_color", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fTexCompressS3TC = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture_compression_s3tc", strExt);
          dCaps[i].fTexRect = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_texture_rectangle", strExt);
          dCaps[i].fFogCoord = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_fog_coord", strExt);
          dCaps[i].fDrawRangeElements = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_draw_range_elements", strExt);
          dCaps[i].fStencilWrap = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_stencil_wrap", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fBlendFuncSep = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_blend_func_separate", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fMultiDrawArrays = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_multi_draw_arrays", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fShadowFunc = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_shadow_funcs", strExt);
          dCaps[i].fStencil2Side = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_stencil_two_side", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fColorSubtable = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_color_subtable", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fConvolution = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_convolution", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fHistogram = 
            gluCheckExtension ((const GLubyte*)"GL_EXT_histogram", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fColorTable = 
            gluCheckExtension ((const GLubyte*)"GL_SGI_color_table", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fColorMatrix = 
            gluCheckExtension ((const GLubyte*)"GL_SGI_color_matrix", strExt) || 
            gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt);
          dCaps[i].fTexEdgeClamp = 
            gluCheckExtension ((const GLubyte*)"GL_SGIS_texture_edge_clamp", strExt) ||
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fGenMipmap = 
            gluCheckExtension ((const GLubyte*)"GL_SGIS_generate_mipmap", strExt);
          dCaps[i].fTexLOD = 
            gluCheckExtension ((const GLubyte*)"GL_SGIS_texture_lod", strExt) ||
            (dCaps[i].glVersion >= 0x0120);
          dCaps[i].fPointCull = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_point_cull_mode", strExt);
          dCaps[i].fTexMirrorOnce = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_texture_mirror_once", strExt);
          dCaps[i].fPNtriangles = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_pn_triangles", strExt) ||
            gluCheckExtension ((const GLubyte*)"GL_ATIX_pn_triangles", strExt);
          dCaps[i].fTextFragShader = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_text_fragment_shader", strExt);
          dCaps[i].fBlendEqSep = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_blend_equation_separate", strExt);
          dCaps[i].fBlendWeightMinMax = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_blend_weighted_minmax", strExt);
          dCaps[i].fCombine3 = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_texture_env_combine3", strExt);
          dCaps[i].fSepStencil = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_separate_stencil", strExt);
          dCaps[i].fArrayRevComps4Byte = 
            gluCheckExtension ((const GLubyte*)"GL_ATI_array_rev_comps_in_4_bytes",strExt);
          dCaps[i].fPointSprite = 
            gluCheckExtension ((const GLubyte*)"GL_NV_point_sprite", strExt);
          dCaps[i].fRegCombiners = 
            gluCheckExtension ((const GLubyte*)"GL_NV_register_combiners", strExt);
          dCaps[i].fRegCombiners2 = 
            gluCheckExtension ((const GLubyte*)"GL_NV_register_combiners2", strExt);
          dCaps[i].fTexEnvCombine4 = 
            gluCheckExtension ((const GLubyte*)"GL_NV_texture_env_combine4", strExt);
          dCaps[i].fBlendSquare = 
            gluCheckExtension ((const GLubyte*)"GL_NV_blend_square", strExt) ||
            (dCaps[i].glVersion >= 0x0140);
          dCaps[i].fFogDist = 
            gluCheckExtension ((const GLubyte*)"GL_NV_fog_distance", strExt);
          dCaps[i].fMultisampleFilterHint = 
            gluCheckExtension ((const GLubyte*)"GL_NV_multisample_filter_hint", strExt);
          dCaps[i].fTexGenReflect = 
            gluCheckExtension ((const GLubyte*)"GL_NV_texgen_reflection", strExt);
          dCaps[i].fTexShader = 
            gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader", strExt);
          dCaps[i].fTexShader2 = 
            gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader2", strExt);
          dCaps[i].fTexShader3 = 
            gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader3", strExt);
          dCaps[i].fDepthClamp = 
            gluCheckExtension ((const GLubyte*)"GL_NV_depth_clamp", strExt);
          dCaps[i].fLightMaxExp = 
            gluCheckExtension ((const GLubyte*)"GL_NV_light_max_exponent", strExt);
          dCaps[i].fRasterPosClip = 
            gluCheckExtension ((const GLubyte*)"GL_IBM_rasterpos_clip", strExt);
          dCaps[i].fConvBorderModes = 
            gluCheckExtension ((const GLubyte*)"GL_HP_convolution_border_modes", strExt) ||
            gluCheckExtension ((const GLubyte*)(const GLubyte*)"GL_ARB_imaging", strExt);

          if (dCaps[i].fTexRect) // only check if extension supported
            glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT,
                           &dCaps[i].maxRectTextureSize);
          else
            dCaps[i].maxRectTextureSize = 0;

          CGLDestroyContext (cglContext);
        }
      }
      CGLSetCurrentContext (curr_ctx); // reset current CGL context
    }
  }
}