Skip to content

Commit

Permalink
renderer/opengl: add comment explaning ogl lock on darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Aug 15, 2024
1 parent 57d8508 commit bc66771
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/renderer/OpenGL.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit bc66771

Please sign in to comment.