Browse Source

Merge pull request #12355 from marcelofg55/osx_vsync3

Implemented vsync OS functions for OS X

[ci skip]
Rémi Verschelde 8 years ago
parent
commit
62f7f62999
2 changed files with 20 additions and 0 deletions
  1. 3 0
      platform/osx/os_osx.h
  2. 17 0
      platform/osx/os_osx.mm

+ 3 - 0
platform/osx/os_osx.h

@@ -219,6 +219,9 @@ public:
 
 	virtual bool _check_internal_feature_support(const String &p_feature);
 
+	virtual void set_use_vsync(bool p_enable);
+	virtual bool is_vsync_enabled() const;
+
 	void run();
 
 	void set_mouse_mode(MouseMode p_mode);

+ 17 - 0
platform/osx/os_osx.mm

@@ -1954,6 +1954,23 @@ Error OS_OSX::move_to_trash(const String &p_path) {
 	return OK;
 }
 
+void OS_OSX::set_use_vsync(bool p_enable) {
+	CGLContextObj ctx = CGLGetCurrentContext();
+	if (ctx) {
+		GLint swapInterval = p_enable ? 1 : 0;
+		CGLSetParameter(ctx, kCGLCPSwapInterval, &swapInterval);
+	}
+}
+
+bool OS_OSX::is_vsync_enabled() const {
+	GLint swapInterval = 0;
+	CGLContextObj ctx = CGLGetCurrentContext();
+	if (ctx) {
+		CGLGetParameter(ctx, kCGLCPSwapInterval, &swapInterval);
+	}
+	return swapInterval ? true : false;
+}
+
 OS_OSX *OS_OSX::singleton = NULL;
 
 OS_OSX::OS_OSX() {