Workaround for broken VSync in Simulate on macOS.

OpenGL VSync became broken again in macOS 13 (https://github.com/glfw/glfw/issues/2249). This workaround is similar to https://github.com/glfw/glfw/pull/2277 but is implemented entirely outside of GLFW.

PiperOrigin-RevId: 516320722
Change-Id: Ib8a651a942f592c74e00ad3c7b22f2dfd156be5f
This commit is contained in:
Saran Tunyasuvunakool
2023-03-13 14:18:37 -07:00
committed by Copybara-Service
parent 3abf2ae2cd
commit 2f0fb1e4ef
9 changed files with 195 additions and 0 deletions
+11
View File
@@ -21,6 +21,11 @@
#include <mujoco/mujoco.h>
#include "platform_ui_adapter.h"
#ifdef __APPLE__
#include <optional>
#include "glfw_corevideo.h"
#endif
namespace mujoco {
class GlfwAdapter : public PlatformUIAdapter {
public:
@@ -61,6 +66,12 @@ class GlfwAdapter : public PlatformUIAdapter {
// store last window information when going to full screen
std::pair<int, int> window_pos_;
std::pair<int, int> window_size_;
#ifdef __APPLE__
// Workaround for perpertually broken OpenGL VSync on macOS,
// most recently https://github.com/glfw/glfw/issues/2249.
std::optional<GlfwCoreVideo> core_video_;
#endif
};
} // namespace mujoco