From 7de65e423f80110fe87beec8bf5c1018997b8cda Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Mon, 12 Dec 2022 11:55:06 +0000 Subject: [PATCH] Fixed opengl issue on MacOS --- amulet_map_editor/api/opengl/canvas/canvas.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/amulet_map_editor/api/opengl/canvas/canvas.py b/amulet_map_editor/api/opengl/canvas/canvas.py index d8110a33..b79a062e 100644 --- a/amulet_map_editor/api/opengl/canvas/canvas.py +++ b/amulet_map_editor/api/opengl/canvas/canvas.py @@ -1,5 +1,6 @@ from typing import Optional import logging +import sys import wx from wx import glcanvas @@ -48,7 +49,16 @@ def __init__(self, parent: wx.Window): style=wx.WANTS_CHARS, ) - self._context = glcanvas.GLContext(self) + if sys.platform == "linux": + # setup the OpenGL context. This apparently fixes Amulet-Team/Amulet-Map-Editor#84 + self._context = glcanvas.GLContext(self) + else: + # This is required for MacOS. Amulet-Team/Amulet-Map-Editor#597 + context_attributes = wx.glcanvas.GLContextAttrs() + context_attributes.CoreProfile().Robust().ResetIsolation().EndList() + self._context = glcanvas.GLContext( + self, ctxAttrs=context_attributes + ) # setup the OpenGL context if not self._context.IsOK(): raise Exception(f"Failed setting up context")