diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-10-23 19:11:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 19:11:53 +0200 |
commit | 62f7f629991c1dadf1cb46c984fb5e9231e9b019 (patch) | |
tree | bdcc4f65946c280429a792b91da1ce74c1520655 | |
parent | 804cab31de3691a3d33f02878f45fa5c8e46cdb2 (diff) | |
parent | ad4000d3765623caeedb2f5f256ef477f8a10ac8 (diff) |
Merge pull request #12355 from marcelofg55/osx_vsync3
Implemented vsync OS functions for OS X
[ci skip]
-rw-r--r-- | platform/osx/os_osx.h | 3 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 05adfeb0f5..420bb50af9 100644 --- a/platform/osx/os_osx.h +++ b/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); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 2c81a02014..e1a01d2b59 100644 --- a/platform/osx/os_osx.mm +++ b/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() { |