Skip to content

Commit

Permalink
Make GL version setting specific to Mac OS only
Browse files Browse the repository at this point in the history
Refining earlier change (kyamagu#214). It turns out that Xvfb's GL behavior on Linux
differ depending on whether there is actual graphic hardware or entirely
headless. The Apple GL settings works on Xvfb on my computer
(AMD Radeon R5 Graphics), but fails in github headless CI.

Fixes kyamagu#266
  • Loading branch information
HinTak committed Sep 20, 2024
1 parent 57e705c commit 5cba584
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 10 additions & 8 deletions docs/tutorial/canvas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ The following example uses glfw package to create an OpenGL context. Install
glfw.window_hint(glfw.VISIBLE, glfw.FALSE)
glfw.window_hint(glfw.STENCIL_BITS, 8)
# see https://www.glfw.org/faq#macos
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if sys.platform.startswith("darwin"):
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
window = glfw.create_window(640, 480, '', None, None)
glfw.make_context_current(window)
yield window
Expand Down Expand Up @@ -144,10 +145,11 @@ Here's a complete example:
raise RuntimeError('glfw.init() failed')
glfw.window_hint(glfw.STENCIL_BITS, 8)
# see https://www.glfw.org/faq#macos
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if sys.platform.startswith("darwin"):
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
window = glfw.create_window(WIDTH, HEIGHT, '', None, None)
glfw.make_context_current(window)
yield window
Expand Down
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ def glfw_context():
glfw.window_hint(glfw.VISIBLE, glfw.FALSE)
glfw.window_hint(glfw.STENCIL_BITS, 8)
# see https://www.glfw.org/faq#macos
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if sys.platform.startswith("darwin"):
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 2)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
context = glfw.create_window(640, 480, '', None, None)
glfw.make_context_current(context)
logger.debug('glfw context created')
Expand Down

0 comments on commit 5cba584

Please sign in to comment.