Skip to content

Commit b866523

Browse files
committed
Check glfw version on startup
1 parent ccd777f commit b866523

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

demosys/view/window.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313

1414
class Window:
15+
min_glfw_version = (3, 2, 1)
16+
1517
def __init__(self):
1618
self.width = settings.WINDOW['size'][0]
1719
self.height = settings.WINDOW['size'][1]
@@ -21,7 +23,7 @@ def __init__(self):
2123
if not glfw.init():
2224
raise ValueError("Failed to initialize glfw")
2325

24-
print("glfw version: {} (python wrapper version {})".format(glfw.get_version(), glfw.__version__))
26+
self.check_glfw_version()
2527

2628
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, settings.OPENGL['version'][0])
2729
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, settings.OPENGL['version'][1])
@@ -81,6 +83,8 @@ def __init__(self):
8183
glfw.make_context_current(self.window)
8284
print("Context Version:", GL.glGetString(GL.GL_VERSION).decode())
8385

86+
# The number of screen updates to wait from the time glfwSwapBuffers
87+
# was called before swapping the buffers and returning
8488
if settings.WINDOW.get('vsync'):
8589
glfw.swap_interval(1)
8690

@@ -107,3 +111,8 @@ def resize(self, width, height):
107111

108112
def terminate(self):
109113
glfw.terminate()
114+
115+
def check_glfw_version(self):
116+
print("glfw version: {} (python wrapper version {})".format(glfw.get_version(), glfw.__version__))
117+
if glfw.get_version() < self.min_glfw_version:
118+
raise ValueError("Please update glfw binaries to version {} or later".format(self.min_glfw_version))

0 commit comments

Comments
 (0)