From bc667714dd5ad2de106d0d00fe47bdcdbefd0060 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 15 Aug 2024 14:25:05 -0700 Subject: [PATCH] renderer/opengl: add comment explaning ogl lock on darwin --- src/renderer/OpenGL.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 1f7fb1ea2..d8aa9b92e 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -2030,6 +2030,12 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void { } } + // In the "OpenGL Programming Guide for Mac" it explains that: "When you + // use an NSOpenGLView object with OpenGL calls that are issued from a + // thread other than the main one, you must set up mutex locking." + // This locks the context and avoids crashes that can happen due to + // races with the underlying Metal layer that Apple is using to + // implement OpenGL. const is_darwin = builtin.target.isDarwin(); const ogl = if (comptime is_darwin) @cImport({ @cInclude("OpenGL/OpenGL.h");