Esempio n. 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;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
void COXDragDockContext::Move(CPoint pt)
{
	CPoint ptOffset = pt - m_ptLast;
	
#ifdef _MAC
    // prevent dragging the floating window completely under the menu bar
    GDHandle hgd = _AfxFindDevice(pt.x, pt.y);
    if (hgd == NULL || hgd == GetMainDevice() ||
		TestDeviceAttribute(hgd, hasAuxMenuBar))
	{
		CRect rect;
		
        if ((HORZF(m_dwStyle) && !m_bFlip) || (VERTF(m_dwStyle) && m_bFlip))
			rect = m_rectFrameDragHorz;
        else
			rect = m_rectFrameDragVert;
		
        // determine our new position
		rect.OffsetRect(ptOffset);
		
        // keep us on the screen if we were getting too close to the menu bar
        int yMBarBottom = (*hgd)->gdRect.top + GetMBarHeight() + 4;
        if (rect.bottom < yMBarBottom)
		{
			pt.y += yMBarBottom - rect.bottom;
            ptOffset.y += yMBarBottom - rect.bottom;
		}
	}
#endif
	
	// offset all drag rects to new position
    m_rectDragHorz.OffsetRect(ptOffset);
    m_rectFrameDragHorz.OffsetRect(ptOffset);
    m_rectDragVert.OffsetRect(ptOffset);
    m_rectFrameDragVert.OffsetRect(ptOffset);
	
	// these rectangles only move in 1 direction

	m_rectDragHorzAlone.top += ptOffset.y;
	m_rectDragHorzAlone.bottom += ptOffset.y;
	m_rectDragVertAlone.left  += ptOffset.x;
	m_rectDragVertAlone.right += ptOffset.x;
	
    m_ptLast = pt;
	
    // if control key is down don't dock
    m_dwOverDockStyle = m_bForceFrame ? 0 : CanDock();
	
    // update feedback
    DrawFocusRect();
}
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);
}
Esempio n. 7
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;
}
Esempio n. 8
0
/*
Esempio n. 9
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 */
}
Esempio n. 10
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;
}
Esempio n. 11
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
    }
  }
}