Debian Codegraph @

examples/opengl/opengl_context.py

raw symbols SCIP
1 """In order to use the features of modern OpenGL versions, you must ask for
2 a specific context version. You can do this by supplying the `major_version`
3 and `minor_version` attributes for a GL Config.
4
5 This example creates an OpenGL 4.2 context, prints the version string to stdout,
6 and exits. Note that some GPU drivers may return a newer version than requested,
7 at their discretion.
8 """
9 import pyglet
10
11 # Specify the OpenGL version explicitly to request 4.2 features
12 #
13 # Some other attributes relevant to OpenGL 3+:
14 # forward_compatible = True To request a context without deprecated
15 # functionality
16 # debug = True To request a debug context
17 config = pyglet.gl.Config(major_version=4, minor_version=2)
18
19 # Create a context matching the above configuration. Will fail if
20 # OpenGL 4.2 is not supported by the driver.
21 window = pyglet.window.Window(config=config, visible=False)
22
23 # Print the version of the context created.
24 print('OpenGL version:', window.context.get_info().get_version())
25
26 window.close()