Skip to main content

pypi rtd

moderngl-window

A cross platform utility library for ModernGL making window creation and resource loading simple. It can also be used with PyOpenGL for rendering with the programmable pipeline.

Please report bugs or post questions/feedback on github.

Features

  • Cross platform support. Tested on Windows 10, Linux and Mac OS X. This can save users a lot of time and is often more difficult than most people imagine it to be.
  • Easily create a window for ModernGL using pyglet, pygame, PySide2, GLFW, SDL2, PyQt5 or tkinter supporting a wide range of window, keyboard and mouse events. These events are unified into a single system so your project can work with any window.
  • Load 2D textures, texture arrays and cube maps using Pillow
  • Load shaders as single or multiple glsl files
  • Load objects/scenes from wavefront/obj, GLTF 2.0 or STL
  • Resource finder system supporting multiple resource directories
  • A highly plugable library supporting custom loaders, resource finders and windows.
  • Type hints everywhere making code completion and linting a breeze

We are not trying to force the user into using every aspect of this library. If you have an exiting project and just need texture loading you will be able to do this without unnecessary hurdles as long as you provide us your moderngl.Context.

Install

pip install moderngl-window

Supported Platforms

  • Windows
  • Linux
  • Mac OS X

Sample Usage

Simple example opening a window clearing every frame using red (color).

# test.py
import moderngl_window as mglw

class Test(mglw.WindowConfig):
    gl_version = (3, 3)

    def on_render(self, time: float, frametime: float):
        self.ctx.clear(1.0, 0.0, 0.0, 0.0)

Test.run()

Run the example with different window backends:

python test.py --window pyglet
python test.py --window pygame2
python test.py --window glfw
python test.py --window sdl2
python test.py --window pyside2
python test.py --window pyqt5
python test.py --window tk

WindowConfig classes are the simplest way to get started without knowing a lot about this library. For more advanced usage see documentation or examples.

Setup from source

We assume the user knows how to handle virtualenvs.

# Install the package in editable mode
$ pip install -e .

# Install development requirements
$ pip install -e .[dev]

Running Tests

With dev requirements installed:

python make.py test

Building Docs

pip install -e .[dev]
python make.py html

Contributing

Contributions are welcome regardless of experience level. Don't hesitate submitting issues, opening partial or completed pull requests.

Plugins

We are interested in contributions providing new loaders, windows etc. For these to be included in this library we require them to work cross platforms (win10/linux/osx) and be fairly easy to set up.

If it requires more than manually downloading a pre-compiled dll (like SDL2, GLFW etc.) it would most likely not be included, but you are welcome to present your case if you still think it should be included.

If you create your own repo/package containing plugins for this library, please make an issue and we'll link back to it. Be sure to include what platforms are supported, install instructions, how you configure it in moderngl-window and of course a clear and concise description of what exactly your package provides.

Citation

If you need to cite this repository in academic research:

@Online{Forselv2020,
  author = {Einar Forselv},
  title = {moderngl-window, a cross-platform windowing/utility library for ModernGL},
  date = {2020-05-01},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/moderngl/moderngl-window}},
  commit = {<insert hash if needed>}
}

If commit hash is required this can be found per release here: https://github.com/moderngl/moderngl-window/releases

Attributions

We can't build everything from scratch. We rely on certain packages and resources to make this project possible.

Windows

Loaders

Testing & Utility

Resources

Some History

The majority of the code in this library comes from demosys-py (somewhat modified). Because demosys-py is a framework we decided to split out a lot useful functionality into this library. Frameworks are a lot less appealing to users and it would be a shame to not make this more available to the ModernGL user base.

Release files for moderngl-window 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moderngl-window 3.1.1
File Size Uploaded
moderngl_window-3.1.1.tar.gz 353.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moderngl-window 3.1.1
File Interpreter ABI Platform
moderngl_window-3.1.1-py3-none-any.whl Python 3 none any Details

Total release size:735.9 kB

Release files / moderngl_window-3.1.1.tar.gz

Download URL moderngl_window-3.1.1.tar.gz
Size 353.5 kB
Tags Source
SHA-256 checksum
How to use checksums
29c2827505f87399f3461d480b2778910fddeebe44ea803301215cf212a6c1bc
BLAKE2b-256 checksum
How to use checksums
900292e235891300c901f59647112a0267a07454f58aeb2041aa44f6b85f9cb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / moderngl_window-3.1.1-py3-none-any.whl

Download URL moderngl_window-3.1.1-py3-none-any.whl
Size 382.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3b3ac2b4e23afcbfdac1971318a4db893bed3ba6a8fbde3367b1226af39b2e5
BLAKE2b-256 checksum
How to use checksums
2341d3503f07de8ad3597165f88b07e1064629f82e65385c4307875b2f6b137f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

3.1.1 This release

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.4.6

2 release files

2.4.5

2 release files

2.4.4

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page