Skip to content

Commit 667cdd8

Browse files
committed
Print context details in glfw windiw
1 parent 3d49c36 commit 667cdd8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

demosys/context/glfw.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import glfw
2-
import moderngl
2+
import sys
33

4-
from OpenGL import GL
4+
import moderngl as mgl
55

66
from demosys.conf import settings
77
from demosys.core.exceptions import ImproperlyConfigured
@@ -40,11 +40,11 @@ def __init__(self):
4040

4141
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
4242
if settings.OPENGL.get('forward_compat'):
43-
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL.GL_TRUE)
43+
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
4444
if not settings.WINDOW.get('resizable'):
45-
glfw.window_hint(glfw.RESIZABLE, GL.GL_FALSE)
45+
glfw.window_hint(glfw.RESIZABLE, False)
4646

47-
glfw.window_hint(glfw.DOUBLEBUFFER, GL.GL_TRUE)
47+
glfw.window_hint(glfw.DOUBLEBUFFER, True)
4848

4949
# glfw.window_hint(glfw.RED_BITS, 8)
5050
# glfw.window_hint(glfw.GREEN_BITS, 8)
@@ -92,15 +92,22 @@ def __init__(self):
9292
print("Actual window size:", glfw.get_window_size(self.window))
9393

9494
glfw.make_context_current(self.window)
95-
print("Context Version:", GL.glGetString(GL.GL_VERSION).decode())
9695

9796
# The number of screen updates to wait from the time glfwSwapBuffers
9897
# was called before swapping the buffers and returning
9998
if settings.WINDOW.get('vsync'):
10099
glfw.swap_interval(1)
101100

102101
# Create mederngl context from existing context
103-
self.ctx = moderngl.create_context()
102+
self.ctx = mgl.create_context()
103+
print("Context Version:")
104+
print('ModernGL:', mgl.__version__)
105+
print('vendor:', self.ctx.info['GL_VENDOR'])
106+
print('renderer:', self.ctx.info['GL_RENDERER'])
107+
print('version:', self.ctx.info['GL_VERSION'])
108+
print('python:', sys.version)
109+
print('platform:', sys.platform)
110+
print('code:', self.ctx.version_code)
104111

105112
def should_close(self):
106113
return glfw.window_should_close(self.window)

0 commit comments

Comments
 (0)