diff --git a/desmume/src/cocoa/DefaultUserPrefs.plist b/desmume/src/cocoa/DefaultUserPrefs.plist
index 2c348c0b0..aec738a81 100644
Binary files a/desmume/src/cocoa/DefaultUserPrefs.plist and b/desmume/src/cocoa/DefaultUserPrefs.plist differ
diff --git a/desmume/src/cocoa/cocoa_globals.h b/desmume/src/cocoa/cocoa_globals.h
index 763102a9e..f789bfd86 100644
--- a/desmume/src/cocoa/cocoa_globals.h
+++ b/desmume/src/cocoa/cocoa_globals.h
@@ -347,6 +347,7 @@ enum
MESSAGE_SET_GPU_STATE_FLAGS,
MESSAGE_CHANGE_DISPLAY_TYPE,
MESSAGE_CHANGE_BILINEAR_OUTPUT,
+ MESSAGE_CHANGE_VERTICAL_SYNC,
MESSAGE_CHANGE_VIDEO_FILTER,
MESSAGE_SET_RENDER3D_METHOD,
MESSAGE_SET_RENDER3D_HIGH_PRECISION_COLOR_INTERPOLATION,
diff --git a/desmume/src/cocoa/cocoa_output.h b/desmume/src/cocoa/cocoa_output.h
index cd0237d93..55de75f77 100644
--- a/desmume/src/cocoa/cocoa_output.h
+++ b/desmume/src/cocoa/cocoa_output.h
@@ -105,6 +105,7 @@
- (void) doRedraw;
- (void) doDisplayTypeChanged:(NSInteger)displayTypeID;
- (void) doBilinearOutputChanged:(BOOL)useBilinear;
+- (void) doVerticalSyncChanged:(BOOL)useVerticalSync;
- (void) doVideoFilterChanged:(NSInteger)videoFilterTypeID;
@property (assign) BOOL isHudEnabled;
@@ -164,6 +165,7 @@
- (void) handleChangeGpuStateFlags:(NSData *)flagsData;
- (void) handleChangeDisplayType:(NSData *)displayTypeIdData;
- (void) handleChangeBilinearOutput:(NSData *)bilinearStateData;
+- (void) handleChangeVerticalSync:(NSData *)verticalSyncStateData;
- (void) handleChangeVideoFilter:(NSData *)videoFilterTypeIdData;
- (void) handleSetRender3DRenderingEngine:(NSData *)methodIdData;
- (void) handleSetRender3DHighPrecisionColorInterpolation:(NSData *)stateData;
diff --git a/desmume/src/cocoa/cocoa_output.mm b/desmume/src/cocoa/cocoa_output.mm
index 12ff0f34f..b4e40c6b3 100644
--- a/desmume/src/cocoa/cocoa_output.mm
+++ b/desmume/src/cocoa/cocoa_output.mm
@@ -1056,7 +1056,11 @@ GPU3DInterface *core3DList[] = {
case MESSAGE_CHANGE_BILINEAR_OUTPUT:
[self handleChangeBilinearOutput:[messageComponents objectAtIndex:0]];
break;
-
+
+ case MESSAGE_CHANGE_VERTICAL_SYNC:
+ [self handleChangeVerticalSync:[messageComponents objectAtIndex:0]];
+ break;
+
case MESSAGE_CHANGE_VIDEO_FILTER:
[self handleChangeVideoFilter:[messageComponents objectAtIndex:0]];
break;
@@ -1189,6 +1193,17 @@ GPU3DInterface *core3DList[] = {
[self handleEmuFrameProcessed:self.frameData];
}
+- (void) handleChangeVerticalSync:(NSData *)verticalSyncStateData
+{
+ if (delegate == nil || ![delegate respondsToSelector:@selector(doVerticalSyncChanged:)])
+ {
+ return;
+ }
+
+ const BOOL *theState = (BOOL *)[verticalSyncStateData bytes];
+ [delegate doVerticalSyncChanged:*theState];
+}
+
- (void) handleChangeVideoFilter:(NSData *)videoFilterTypeIdData
{
if (delegate == nil || ![delegate respondsToSelector:@selector(doVideoFilterChanged:)])
diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings
index 7a61af0db..f66e4b31c 100644
Binary files a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings and b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings differ
diff --git a/desmume/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 @@
@@ -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
- {{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
- {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