From a5a03613f109106f546c15886d021080f7f65a54 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 7 Aug 2012 03:57:23 +0000 Subject: [PATCH] Cocoa Port: - Add vertical sync feature. --- desmume/src/cocoa/DefaultUserPrefs.plist | Bin 4992 -> 5031 bytes desmume/src/cocoa/cocoa_globals.h | 1 + desmume/src/cocoa/cocoa_output.h | 2 + desmume/src/cocoa/cocoa_output.mm | 17 +- .../English.lproj/MainMenu.strings | Bin 261724 -> 263600 bytes .../translations/English.lproj/MainMenu.xib | 243 ++++++++++++++---- desmume/src/cocoa/userinterface/displayView.h | 5 + .../src/cocoa/userinterface/displayView.mm | 66 ++++- .../cocoa/userinterface/emuWindowDelegate.h | 1 + .../cocoa/userinterface/emuWindowDelegate.mm | 7 + 10 files changed, 291 insertions(+), 51 deletions(-) diff --git a/desmume/src/cocoa/DefaultUserPrefs.plist b/desmume/src/cocoa/DefaultUserPrefs.plist index 2c348c0b0d55381f9c2ee4f320c59a3036cdd116..aec738a8160e04223739fa0748aa73f53734eef8 100644 GIT binary patch delta 1646 zcmYk5d3;Sr6vuz(y?5s>bLZacBBBV1EeMG%gtV&mr43^FP)jwRXj4lOL~4nxsJ1E| zRZ&aqJBfX-YHO*W+%%Tj+Ei;7d#!zW9v?HGIcLuKp5M$LGiOZYWtI7d1N$W<4~dF8 zZ`DcXeG{Wm7tx481K(=sn}u;h-#*%xDI|rqa5hCVUsM>k^v8v}mo;(zOhccIFU(O# zKPyy4Q&-fb_p|awQb;eWRMVv7f&F@?c1}u6>D4JYv2)_!AxR0n`^BdYNZ1hXn(QXU zdqxWP$}A%C6ZFMr7>}u#jfGf)&De`WIDtR#H?HFzo{>xzm81$(oua9kwMDk}(8BF$^gfj#R{W+o{F8hCJFH;b0_2VKmY(24gV}!@LWONNVKTnJ6nu%V@UBLJhOmI#`GG$U-(YU?VmK)MwQS zL0fXM72B{KJFpYGup4{u!z*>1{iB0@_z6Gb7wpFY91JLTY31!-9UMjuj^HSc;Wr%j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src/cocoa/translations/English.lproj/MainMenu.xib b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib index e52dc1b40..6f77ed66c 100644 --- a/desmume/src/cocoa/translations/English.lproj/MainMenu.xib +++ b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib @@ -12,8 +12,9 @@ YES + - + YES @@ -5107,7 +5108,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES - AAAACAAAAA8AAAALAAAAAQAAAAwAAAAQAAAAAA + AAAABQAAAAgAAAAPAAAACwAAAAEAAAAMAAAAEAAAAAA @@ -7028,14 +7029,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 12 - {{13, 10}, {463, 381}} + {{13, 10}, {463, 401}} YES 1 - + 256 YES @@ -7429,7 +7430,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {{6, 118}, {431, 116}} + {{6, 127}, {431, 116}} {0, 0} @@ -7450,8 +7451,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA NO - {{10, 33}, {443, 335}} - + {{10, 33}, {443, 355}} Display Views @@ -7460,14 +7460,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 2 - + 256 YES 268 - {{118, 274}, {151, 26}} + {{118, 278}, {151, 26}} YES @@ -7710,7 +7710,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA NeXT TIFF v4.0 pasteboard type - {{118, 5}, {262, 262}} + {{118, 9}, {262, 262}} YES @@ -7727,7 +7727,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{10, 247}, {106, 17}} + {{10, 251}, {106, 17}} YES @@ -7743,7 +7743,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{10, 280}, {106, 17}} + {{10, 284}, {106, 17}} YES @@ -7759,7 +7759,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{119, 308}, {196, 18}} + {{119, 328}, {196, 18}} YES @@ -7778,8 +7778,31 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 25 + + + 268 + {{119, 308}, {154, 18}} + + YES + + -2080244224 + 0 + Use Vertical Sync + + + 1211912703 + 2 + + + + + 200 + 25 + + - {{10, 33}, {443, 335}} + {{10, 33}, {443, 355}} + Video Output @@ -8041,7 +8064,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {{74, 69}, {295, 141}} + {{74, 81}, {295, 141}} {0, 0} @@ -8064,7 +8087,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{217, 285}, {152, 26}} + {{217, 297}, {152, 26}} YES @@ -8121,7 +8144,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{74, 291}, {141, 17}} + {{74, 303}, {141, 17}} YES @@ -8137,7 +8160,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{250, 22}, {165, 26}} + {{250, 34}, {165, 26}} YES @@ -8216,7 +8239,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{28, 28}, {220, 17}} + {{28, 40}, {220, 17}} YES @@ -8266,7 +8289,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {{74, 214}, {295, 54}} + {{74, 226}, {295, 54}} {0, 0} @@ -8287,25 +8310,25 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA NO - {{10, 33}, {443, 335}} + {{10, 33}, {443, 355}} 3D Rendering - + 0 YES YES YES - + - {489, 405} + {489, 425} NSView @@ -14874,7 +14897,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 279 2 - {{1651, 316}, {204, 481}} + {{1651, 296}, {204, 501}} -461896704 Video Output Settings NSPanel @@ -14890,7 +14913,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{25, 18}, {154, 19}} - YES -2080244224 @@ -14921,7 +14943,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{18, 14}, {129, 358}} - YES 18 1 @@ -15406,12 +15427,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {168, 382}} - {{17, 41}, {170, 398}} - {0, 0} 67239424 @@ -15433,9 +15452,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 445}, {169, 18}} + {{17, 465}, {169, 18}} - YES -2080244224 @@ -15453,10 +15471,31 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 25 + + + 268 + {{17, 445}, {135, 18}} + + YES + + -2080244224 + 131072 + Use Vertical Sync + + + 1211912703 + 2 + + + + + 200 + 25 + + - {204, 481} + {204, 501} - {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} @@ -19268,6 +19307,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA scale rotation useBilinearOutput + useVerticalSync YES @@ -28222,6 +28262,46 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 6158 + + + value: values.DisplayView_UseVerticalSync + + + + + + value: values.DisplayView_UseVerticalSync + value + values.DisplayView_UseVerticalSync + 2 + + + 6164 + + + + value: selection.useVerticalSync + + + + + + value: selection.useVerticalSync + value + selection.useVerticalSync + 2 + + + 6166 + + + + changeVerticalSync: + + + + 6167 + @@ -28828,9 +28908,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES - + + @@ -30550,11 +30631,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES + + - @@ -38579,6 +38661,34 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA + + 6159 + + + YES + + + + + + 6160 + + + + + 6161 + + + YES + + + + + + 6162 + + + @@ -40467,6 +40577,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 6134.IBAttributePlaceholdersKey 6134.IBPluginDependency 6135.IBPluginDependency + 6159.IBAttributePlaceholdersKey + 6159.IBPluginDependency + 6159.IBViewBoundsToFrameTransform + 6160.IBPluginDependency + 6161.IBAttributePlaceholdersKey + 6161.IBPluginDependency + 6162.IBPluginDependency 627.IBEditorWindowLastContentRect 627.IBPluginDependency 627.IBWindowTemplateEditedContentRect @@ -41240,7 +41357,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{391, 644}, {489, 405}} + {{712, 677}, {489, 425}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -41275,7 +41392,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABBUAAAw8KAAA + P4AAAL+AAABBUAAAw8yAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -41289,7 +41406,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABC7AAAw7gAAA + P4AAAL+AAABC6AAAw5QAAA com.apple.InterfaceBuilder.CocoaPlugin {{531, 545}, {151, 363}} @@ -41299,12 +41416,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - AULsAABCigAAA + AULoAABAQAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABBIAAAw6MAAA + P4AAAL+AAABBAAAAw4IAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -41323,7 +41440,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABBIAAAw7aAAA + P4AAAL+AAABBAAAAw5KAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -42106,9 +42223,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{1243, 702}, {256, 408}} + {{1029, 702}, {256, 408}} com.apple.InterfaceBuilder.CocoaPlugin - {{1243, 702}, {256, 408}} + {{1029, 702}, {256, 408}} {{33, 99}, {480, 360}} @@ -42306,7 +42423,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - AUGwAABDNwAAA + AUGIAABCJAAAA com.apple.InterfaceBuilder.CocoaPlugin @@ -44380,6 +44497,29 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Enable to use vertical sync on the video output. This setting eliminates screen tearing, but may also reduce the video frame rate. + + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBiAAAw+aAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Enable to use vertical sync on the video output by default. This setting eliminates screen tearing, but may also reduce the video frame rate. + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{609, 360}, {400, 100}} com.apple.InterfaceBuilder.CocoaPlugin {{609, 360}, {400, 100}} @@ -44443,9 +44583,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin - {{1069, 659}, {204, 481}} + {{1422, 661}, {204, 501}} com.apple.InterfaceBuilder.CocoaPlugin - {{1069, 659}, {204, 481}} + {{1422, 661}, {204, 501}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -44498,7 +44638,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABBuAAAwgwAAA + P4AAAL+AAABByAAAwgwAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -44759,7 +44899,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 6158 + 6167 @@ -45287,6 +45427,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA changeSpuInterpolationMode: changeSpuSyncMethod: changeSpuSyncMode: + changeVerticalSync: changeVideoFilter: changeVolume: cheatsDisable: @@ -45378,6 +45519,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA id id id + id @@ -45406,6 +45548,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA changeSpuInterpolationMode: changeSpuSyncMethod: changeSpuSyncMode: + changeVerticalSync: changeVideoFilter: changeVolume: cheatsDisable: @@ -45530,6 +45673,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA changeSpuSyncMode: id + + changeVerticalSync: + id + changeVideoFilter: id diff --git a/desmume/src/cocoa/userinterface/displayView.h b/desmume/src/cocoa/userinterface/displayView.h index fafaec1dc..6666355a2 100644 --- a/desmume/src/cocoa/userinterface/displayView.h +++ b/desmume/src/cocoa/userinterface/displayView.h @@ -39,6 +39,7 @@ - (void) doRedraw; - (void) doDisplayTypeChanged:(NSInteger)displayTypeID; - (void) doBilinearOutputChanged:(BOOL)useBilinear; +- (void) doVerticalSyncChanged:(BOOL)useVerticalSync; - (void) doVideoFilterChanged:(NSInteger)videoFilterTypeID; @end @@ -63,6 +64,7 @@ OSSpinLock spinlockScale; OSSpinLock spinlockRotation; OSSpinLock spinlockUseBilinearOutput; + OSSpinLock spinlockUseVerticalSync; } @property (retain) NSView *view; @@ -72,6 +74,7 @@ @property (assign) double scale; @property (assign) double rotation; @property (assign) BOOL useBilinearOutput; +@property (assign) BOOL useVerticalSync; @property (assign) NSInteger displayType; @property (readonly) NSMutableDictionary *bindings; @@ -83,6 +86,8 @@ - (double) rotation; - (void) setUseBilinearOutput:(BOOL)theState; - (BOOL) useBilinearOutput; +- (void) setUseVerticalSync:(BOOL)theState; +- (BOOL) useVerticalSync; - (void) setDisplayType:(NSInteger)theType; - (NSInteger) displayType; - (void) setVideoFilterType:(NSInteger)theType; diff --git a/desmume/src/cocoa/userinterface/displayView.mm b/desmume/src/cocoa/userinterface/displayView.mm index 1355ce62b..3eb96ff77 100644 --- a/desmume/src/cocoa/userinterface/displayView.mm +++ b/desmume/src/cocoa/userinterface/displayView.mm @@ -41,6 +41,7 @@ @dynamic scale; @dynamic rotation; @dynamic useBilinearOutput; +@dynamic useVerticalSync; @dynamic displayType; @synthesize bindings; @@ -67,6 +68,7 @@ spinlockScale = OS_SPINLOCK_INIT; spinlockRotation = OS_SPINLOCK_INIT; spinlockUseBilinearOutput = OS_SPINLOCK_INIT; + spinlockUseVerticalSync = OS_SPINLOCK_INIT; normalSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2.0); sendPortDisplay = nil; @@ -91,6 +93,7 @@ [bindings setValue:[NSNumber numberWithDouble:1.0] forKey:@"scale"]; [bindings setValue:[NSNumber numberWithDouble:0.0] forKey:@"rotation"]; [bindings setValue:[NSNumber numberWithBool:YES] forKey:@"useBilinearOutput"]; + [bindings setValue:[NSNumber numberWithBool:NO] forKey:@"useVerticalSync"]; [bindings setValue:[NSNumber numberWithInteger:DS_DISPLAY_TYPE_COMBO] forKey:@"displayMode"]; [bindings setValue:@"Combo" forKey:@"displayModeString"]; [bindings setValue:[NSNumber numberWithInteger:VideoFilterTypeID_None] forKey:@"videoFilterType"]; @@ -193,6 +196,24 @@ return theState; } +- (void) setUseVerticalSync:(BOOL)theState +{ + OSSpinLockLock(&spinlockUseVerticalSync); + [bindings setValue:[NSNumber numberWithBool:theState] forKey:@"useVerticalSync"]; + OSSpinLockUnlock(&spinlockUseVerticalSync); + + [CocoaDSUtil messageSendOneWayWithBool:self.sendPortDisplay msgID:MESSAGE_CHANGE_VERTICAL_SYNC boolValue:theState]; +} + +- (BOOL) useVerticalSync +{ + OSSpinLockLock(&spinlockUseVerticalSync); + BOOL theState = [[bindings valueForKey:@"useVerticalSync"] boolValue]; + OSSpinLockUnlock(&spinlockUseVerticalSync); + + return theState; +} + - (void) setDisplayType:(NSInteger)theType { NSSize theSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT); @@ -514,6 +535,16 @@ [view doBilinearOutputChanged:useBilinear]; } +- (void) doVerticalSyncChanged:(BOOL)useVerticalSync +{ + if (view == nil || ![view respondsToSelector:@selector(doVerticalSyncChanged:)]) + { + return; + } + + [view doVerticalSyncChanged:useVerticalSync]; +} + - (void) doVideoFilterChanged:(NSInteger)videoFilterTypeID { if (view == nil || ![view respondsToSelector:@selector(doVideoFilterChanged:)]) @@ -842,7 +873,7 @@ glEnd(); - glFlush(); + CGLFlushDrawable((CGLContextObj)[[self openGLContext] CGLContextObj]); } - (void) uploadFrameTexture:(const GLvoid *)frameBytes textureSize:(NSSize)textureSize @@ -987,31 +1018,47 @@ GLfloat rotation = (GLfloat)[dispViewDelegate rotation]; NSRect rect = [self frame]; + CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); + [[self openGLContext] makeCurrentContext]; SetupOpenGLView((GLsizei)rect.size.width, (GLsizei)rect.size.height, scale, rotation); + CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); + [dispViewDelegate setViewToBlack]; } - (void)doProcessVideoFrame:(const void *)videoFrameData frameSize:(NSSize)frameSize { - [[self openGLContext] makeCurrentContext]; + CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); + + [[self openGLContext] makeCurrentContext]; [self uploadFrameTexture:(const GLvoid *)videoFrameData textureSize:frameSize]; lastFrameSize = frameSize; [self drawVideoFrame]; + + CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); } - (void)doResizeView:(NSRect)rect { + CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); + [[self openGLContext] makeCurrentContext]; SetupOpenGLView((GLsizei)rect.size.width, (GLsizei)rect.size.height, (GLfloat)[dispViewDelegate scale], (GLfloat)[dispViewDelegate rotation]); [[self openGLContext] update]; + + CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); } - (void)doRedraw { + CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); + [[self openGLContext] makeCurrentContext]; [self drawVideoFrame]; + + CGLUnlockContext((CGLContextObj)[[self openGLContext] CGLContextObj]); } - (void) doBilinearOutputChanged:(BOOL)useBilinear @@ -1023,6 +1070,21 @@ } } +- (void) doVerticalSyncChanged:(BOOL)useVerticalSync +{ + GLint swapInt = 1; + + if (useVerticalSync) + { + [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; + } + else + { + swapInt = 0; + [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; + } +} + - (void)doVideoFilterChanged:(NSInteger)videoFilterTypeID { glTexPixelFormat = GL_UNSIGNED_INT_8_8_8_8_REV; diff --git a/desmume/src/cocoa/userinterface/emuWindowDelegate.h b/desmume/src/cocoa/userinterface/emuWindowDelegate.h index f8552dfc3..323b3dfa7 100644 --- a/desmume/src/cocoa/userinterface/emuWindowDelegate.h +++ b/desmume/src/cocoa/userinterface/emuWindowDelegate.h @@ -187,6 +187,7 @@ - (IBAction) changeRotation:(id)sender; - (IBAction) changeRotationRelative:(id)sender; - (IBAction) changeBilinearOutput:(id)sender; +- (IBAction) changeVerticalSync:(id)sender; - (IBAction) changeDisplayMode:(id)sender; - (IBAction) changeVideoFilter:(id)sender; - (IBAction) change3DRenderMethod:(id)sender; diff --git a/desmume/src/cocoa/userinterface/emuWindowDelegate.mm b/desmume/src/cocoa/userinterface/emuWindowDelegate.mm index 27a384117..23e4cb83c 100644 --- a/desmume/src/cocoa/userinterface/emuWindowDelegate.mm +++ b/desmume/src/cocoa/userinterface/emuWindowDelegate.mm @@ -850,6 +850,11 @@ [dispViewDelegate setUseBilinearOutput:[CocoaDSUtil getIBActionSenderButtonStateBool:sender]]; } +- (IBAction) changeVerticalSync:(id)sender +{ + [dispViewDelegate setUseVerticalSync:[CocoaDSUtil getIBActionSenderButtonStateBool:sender]]; +} + - (IBAction) changeDisplayMode:(id)sender { [dispViewDelegate setDisplayType:[CocoaDSUtil getIBActionSenderTag:sender]]; @@ -1942,6 +1947,7 @@ // Setup the window display view per user preferences. [[self dispViewDelegate] setVideoFilterType:[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"]]; [[self dispViewDelegate] setUseBilinearOutput:[[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"]]; + [[self dispViewDelegate] setUseVerticalSync:[[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseVerticalSync"]]; // Set the 3D rendering options per user preferences. [[self dispViewDelegate] setRender3DThreads:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_Threads"]]; @@ -1972,6 +1978,7 @@ [[NSUserDefaults standardUserDefaults] setInteger:[[dispViewBindings valueForKey:@"videoFilterType"] integerValue] forKey:@"DisplayView_VideoFilter"]; [[NSUserDefaults standardUserDefaults] setBool:[[dispViewBindings valueForKey:@"useBilinearOutput"] boolValue] forKey:@"DisplayView_UseBilinearOutput"]; + [[NSUserDefaults standardUserDefaults] setBool:[[dispViewBindings valueForKey:@"useVerticalSync"] boolValue] forKey:@"DisplayView_UseVerticalSync"]; } - (IBAction) writeDefaults3DRenderingSettings:(id)sender