Easily create a window for ModernGL using the most popular window libraries
Project description
moderngl_window
A support library for ModernGL making programmers more efficent and ensuring cross platform support.
- moderngl_window documentation (WIP)
- moderngl_window on PyPI
- moderngl_window on Github
- ModernGL
Features
- Easily create a window for ModernGL using Pyglet, PySide2, GLFW, SDL2 or PyQt5 supporing basic keyboard and mouse controls. These events are unified into a single system so we can switch to any window at any point in time.
- Load 2D textures and texture arrays
- 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 pluggable library supporting custom loaders, resource finders and windows.
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
.
Supported Platforms
- Windows
- Linux
- Mac OS X
Sample Usage
Simple example opening a window clearing every frame using red (color).
import moderngl_window as mglw
class Test(mglw.WindowConfig):
gl_version = (3, 3)
def __init__(self, **kwargs):
super().__init__(**kwargs)
def render(self, time, frametime):
self.ctx.clear(1.0, 0.0, 0.0, 0.0)
mglw.run_window_config(Test)
WindowConfig
classes are the simplest way to get started without knowing
a lot about this library. For more advanced usage see documenation
or examples.
Setup from source
We assume the user knows how to handle vitrualenvs.
# Install the package in editable mode
$ pip install -e .
# Set up and dev requirements
pip install -r requirements.txt
pip install -r tests/requirements.txt
Running Tests
Tests are set up with tox
running pytest with coverate and flake8.
pip install -r tests/requirements.txt
tox
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 precompiled dll (like SDL2, GLEW 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 suppored, install
instructions, how you configure it in moderngl_window
and
of course a clear and concise description of what exactly
your package provides.
Attributions
We can't build everything from scratch. We rely on certain packages and resources to make this project possible.
Windows
- Pyglet (https://github.com/pyglet/pyglet)
- pyGLFW (https://github.com/FlorianRhiem/pyGLFW)
- PySDL2 (https://github.com/marcusva/py-sdl2)
- PySide2 (https://wiki.qt.io/Qt_for_Python)
- PyQt5 (https://www.riverbankcomputing.com/software/pyqt/intro)
Loaders
- Pillow (https://python-pillow.org/)
- pywavefront (https://github.com/pywavefront/PyWavefront)
- trimesh (https://github.com/mikedh/trimesh)
Testing & Utility
- Pyrr (https://github.com/adamlwgriffiths/Pyrr)
- numpy (https://github.com/numpy/numpy)
- pytest (https://docs.pytest.org/en/latest/)
- flake8 (https://gitlab.com/pycqa/flake8)
- coverage (https://github.com/nedbat/coveragepy)
- tox (https://tox.readthedocs.io/en/latest/)
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 funtionality into this
library. Frameworks are a lot less appealing to users and it would be a shame to not make this
more avaialble to the ModernGL user base.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for moderngl_window-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eab966397ab2f0ea250ebeb1837577c9198a61c29c27fa0fb45bf26e2b2cf408 |
|
MD5 | 1d56e553c04c08235be7b7b6ad17478b |
|
BLAKE2b-256 | 64d8d3d146b6742f8cc0d80fa19354c9d3807eedcb234685c4400914ea8479fb |