Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moderngl/moderngl-window
A cross platform utility library for ModernGL making window creation and resource loading simple
https://github.com/moderngl/moderngl-window
hacktoberfest library moderngl moderngl-window opengl python
Last synced: 4 days ago
JSON representation
A cross platform utility library for ModernGL making window creation and resource loading simple
- Host: GitHub
- URL: https://github.com/moderngl/moderngl-window
- Owner: moderngl
- License: mit
- Created: 2019-02-25T12:05:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-06T15:55:35.000Z (20 days ago)
- Last Synced: 2024-12-15T01:05:53.227Z (11 days ago)
- Topics: hacktoberfest, library, moderngl, moderngl-window, opengl, python
- Language: Python
- Homepage:
- Size: 29.4 MB
- Stars: 247
- Watchers: 8
- Forks: 61
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![pypi](https://badge.fury.io/py/moderngl-window.svg)](https://pypi.python.org/pypi/moderngl-window) [![rtd](https://readthedocs.org/projects/moderngl-window/badge/?version=latest)](https://moderngl-window.readthedocs.io)
# moderngl-window
A cross platform utility library for [ModernGL](https://github.com/moderngl/moderngl) making window
creation and resource loading simple. It can also be used with PyOpenGL for
rendering with the programmable pipeline.* [moderngl-window Documentation](https://moderngl-window.readthedocs.io)
* [moderngl-window on PyPI](https://pypi.org/project/moderngl-window)
* [moderngl-window on Github](https://github.com/moderngl/moderngl-window)
* [ModernGL](https://github.com/moderngl/moderngl)
* [ModernGL Discord Server](https://discord.gg/UEMtW8D)Please report bugs or post questions/feedback on [github](https://github.com/moderngl/moderngl-window/issues).
## 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 breezeWe 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
```bash
pip install moderngl-window
```## Supported Platforms
* [x] Windows
* [x] Linux
* [x] Mac OS X## Sample Usage
Simple example opening a window clearing every frame using red (color).
```py
# test.py
import moderngl_window as mglwclass 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:
```bash
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.
```bash
# Install the package in editable mode
$ pip install -e .# Install development requirements
$ pip install -e .[dev]
```## Running Tests
With dev requirements installed:
```bash
python make.py test
```## Building Docs
```bash
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:
```txt
@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 = {}
}
```If commit hash is required this can be found per release here:
## Attributions
We can't build everything from scratch. We rely on certain packages
and resources to make this project possible.### Windows
* pyglet ()
* pygame ()
* pyGLFW ()
* PySDL2 ()
* PySide2 ()
* PyQt5 ()
* tkinter ()### Loaders
* Pillow ()
* pywavefront ()
* trimesh ()### Testing & Utility
* PyGLM ()
* ruff ()
* numpy ()
* pytest ()
* coverage ()## Resources
* NASA 3D Resources ()
* glTF Sample Models ()## Some History
The majority of the code in this library comes from [demosys-py](https://github.com/Contraz/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.