FullScreenWindow.m
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:2k
源码类别:

OpenGL

开发平台:

Visual C++

  1. //
  2. //  FullScreenWindow.m
  3. //  celestia
  4. //
  5. //  Created by Da Woon Jung on Wed Jul 21 2004.
  6. //  Copyright 2005 Da Woon Jung. All rights reserved.
  7. //
  8. #import "FullScreenWindow.h"
  9. @implementation FullScreenWindow
  10. - (id) initWithScreen: (NSScreen *) screen
  11. {
  12.     CGDirectDisplayID displayID = screen ? (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue] : kCGDirectMainDisplay;
  13.     NSRect fullScreenRect = NSMakeRect(0, 0, CGDisplayPixelsWide(displayID), CGDisplayPixelsHigh(displayID));
  14.     self = [super initWithContentRect:fullScreenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES screen:screen];
  15.     return self;
  16. }
  17. - (BOOL) canBecomeKeyWindow
  18. {
  19.     return YES;
  20. }
  21. - (BOOL)canBecomeMainWindow
  22. {
  23.     return YES;
  24. }
  25. - (void) fadeOutScreen
  26. {
  27.     CGDirectDisplayID displayID = (CGDirectDisplayID)[[[[self screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
  28.     
  29.     // Fade to black
  30.     CGGammaValue redMin, redMax, redGamma, greenMin, greenMax, greenGamma, blueMin, blueMax, blueGamma;
  31.     double fadeValue;
  32.     
  33.     CGGetDisplayTransferByFormula(displayID,
  34.                                   &redMin, &redMax, &redGamma,
  35.                                   &greenMin, &greenMax, &greenGamma,
  36.                                   &blueMin, &blueMax, &blueGamma);
  37.     
  38.     for (fadeValue = 1.0; fadeValue >= 0.0; fadeValue -= 0.2 ) {
  39.         CGSetDisplayTransferByFormula(displayID,
  40.                                       redMin, fadeValue*redMax, redGamma,
  41.                                       greenMin, fadeValue*greenMax, greenGamma,
  42.                                       blueMin, fadeValue*blueMax, blueGamma);
  43.         [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 0.05]];
  44.     }    
  45. }
  46. - (void) restoreScreen
  47. {
  48.     CGDisplayRestoreColorSyncSettings();
  49. }
  50. @end