Skip to content

Commit

Permalink
Fixed opengl issue on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Dec 12, 2022
1 parent 0d92fd8 commit 7de65e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion amulet_map_editor/api/opengl/canvas/canvas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional
import logging
import sys

import wx
from wx import glcanvas
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 7de65e4

Please sign in to comment.