moderngl_window

General helper functions aiding in the boostrapping of this library.

moderngl_window.setup_basic_logging(level: int)[source]

Set up basic logging

Parameters

level (int) – The log level

moderngl_window.activate_context(window: moderngl_window.context.base.window.BaseWindow = None, ctx: moderngl.context.Context = None)[source]

Register the active window and context. If only a window is supplied the context is taken from the window. Only a context can also be passed in.

Keyword Arguments
  • window (window) – The window to activate

  • ctx (moderngl.Context) – The moderngl context to activate

moderngl_window.window()[source]

Obtain the active window

moderngl_window.ctx()[source]

Obtain the active context

moderngl_window.get_window_cls(window: str = None) → Type[moderngl_window.context.base.window.BaseWindow][source]

Attempt to obtain a window class using the full dotted python path. This can be used to import custom or modified window classes.

Parameters

window (str) – Name of the window

Returns

A reference to the requested window class. Raises exception if not found.

moderngl_window.get_local_window_cls(window: str = None) → Type[moderngl_window.context.base.window.BaseWindow][source]

Attempt to obtain a window class in the moderngl_window package using short window names such as pyglet or glfw.

Parameters

window (str) – Name of the window

Returns

A reference to the requested window class. Raises exception if not found.

moderngl_window.find_window_classes() → List[str][source]

Find available window packages

Returns

A list of available window packages

moderngl_window.create_window_from_settings() → moderngl_window.context.base.window.BaseWindow[source]

Creates a window using configured values in moderngl_window.conf.Settings.WINDOW. This will also activate the window/context.

Returns

The Window instance

moderngl_window.run_window_config(config_cls: moderngl_window.context.base.window.WindowConfig, timer=None, args=None) → None[source]

Run an WindowConfig entering a blocking main loop

Parameters
  • config_cls – The WindowConfig class to render

  • args – Override sys.args

moderngl_window.create_parser()[source]

Create an argparser parsing the standard arguments for WindowConfig

moderngl_window.parse_args(args=None, parser=None)[source]

Parse arguments from sys.argv

Passing in your own argparser can be user to extend the parser.

Keyword Arguments
  • args – override for sys.argv

  • parser – Supply your own argparser instance