Skip to main content


[![preview](https://github.com/cprogrammer1994/ModernGL/raw/master/.github/preview.png)](#readme)



# ModernGL

```sh
pip install ModernGL
```

- [Documentation](https://moderngl.readthedocs.io/)
- [Examples](https://github.com/cprogrammer1994/ModernGL/tree/master/examples/#readme)
- [ModernGL on Github](https://github.com/cprogrammer1994/ModernGL/)
- [ModernGL on PyPI](https://pypi.org/project/ModernGL/)

## Features

- GPU accelerated high quality graphics
- Rendering modern OpenGL scenes with less headache
- Simpler and faster than PyOpenGL
- Can render without a window
- 100% Pythonic

## Sample usage

```py
>>> import moderngl
>>> ctx = moderngl.create_standalone_context()
>>> buf = ctx.buffer(b'Hello World!') # allocated on the GPU
>>> buf.read()
b'Hello World!'
```

For complete examples please visit the [Examples](https://github.com/cprogrammer1994/ModernGL/tree/master/examples/#readme).

## Easy to use with Pillow and Numpy

```py
>>> img = Image.open('texture.jpg')
>>> ctx.texture(img.size, 3, img.tobytes())
<Texture: 1>
```

```py
>>> ctx.buffer(np.array([0.0, 0.0, 1.0, 1.0], dtype='f4'))
<Buffer: 1>
```

## Compared to PyOpenGL

With the original OpenGL API you have to write a couple of lines to achieve a **simple task** like compiling a shader or running a computation on the GPU. With ModernGL you will need just a **few lines** to achieve the same result.

#### Using PyOpenGL

```py
vbo1 = glGenBuffers(1)
GL.glBindBuffer(GL_ARRAY_BUFFER, vbo1)
GL.glBufferData(GL_ARRAY_BUFFER, b'Hello World!', GL_STATIC_DRAW)

vbo2 = glGenBuffers(1)
GL.glBindBuffer(GL_ARRAY_BUFFER, vbo2)
GL.glBufferData(GL_ARRAY_BUFFER, b'\x00' * 1024, GL_DYNAMIC_DRAW)
```

#### Using ModernGL

```py
vbo1 = ctx.buffer(b'Hello World!')
vbo2 = ctx.buffer(reserve=1024, dynamic=True)
```

## Build

[![build](https://img.shields.io/travis/cprogrammer1994/ModernGL/master.svg?label=build)](https://travis-ci.org/cprogrammer1994/ModernGL)
[![build](https://img.shields.io/appveyor/ci/cprogrammer1994/ModernGL/master.svg?label=build)](https://ci.appveyor.com/project/cprogrammer1994/ModernGL)

```sh
python setup.py build_ext --inplace
```

## FAQ

### Is ModernGL faster than PyOpenGL?

In some cases **yes**, the core functions of ModernGL are written in C++, OpenGL functions are called in quick succession so these calls together count as a single python function call.

### What version of OpenGL is used?

Most of the calls only require **OpenGL 3.3** but Subroutines and Compute Shaders require **OpenGL 4.0** and **OpenGL 4.3**

### Is my old PC supported?

OpenGL 3.3 came out in February 2010. With **up to date drivers** you will be able to use the most of the ModernGL functions, even on integrated graphics cards. _(No, Compute Shaders won't work)_

### Where can I use ModernGL?

**Anywhere where OpenGL is supported.** ModernGL is capable of rendering using a [standalone_context] as well. Rendering to a window only requires a valid OpenGL context.

[standalone_context]: https://github.com/cprogrammer1994/ModernGL/tree/master/examples/standalone

### Can ModernGL create a Window?

**NO**, Window creation is up to you. You can choose from a large variety of modules that can create a window: [PyQt5], [pyglet], [pygame], [GLUT] and many others.

[PyQt5]: https://pypi.org/project/PyQt5/
[pyglet]: https://bitbucket.org/pyglet/pyglet/wiki/Home
[pygame]: https://www.pygame.org/news
[GLUT]: https://wiki.python.org/moin/PyOpenGL

### Limitations using ModernGL over PyOpenGL?

All the neccessary calls are (or can be) implemented in ModernGL. However you can interract with the ModernGL objects from PyOpenGL. If something is missing write an [issue](https://github.com/cprogrammer1994/ModernGL/issues) or raise a [PR](https://github.com/cprogrammer1994/ModernGL/pulls).

## Supported platforms

- [x] Windows
- [x] Linux
- [x] Mac

## Installing from source

### Installing on Ubuntu from source

```sh
apt-get install python3-dev libgl1-mesa-dev libx11-dev
python3 setup.py install
```

### Building the sphinx documentation

```sh
pip install -r docs/requirements.txt
python setup.py build_sphinx
```

### Running tests

```sh
pytest
```

> Some of the tests may be skipped when the supported OpenGL version is below the requirements of the given test.

### Headless rendering

```sh
apt-get install xvfb
alias xpy='xvfb-run -s "-screen 0 1x1x24" python3'
xpy -m ModernGL
```

## Code quality

Code is tested with [pep8], [flake8], [prospector] and [pylint]

[pep8]: https://www.python.org/dev/peps/pep-0008/
[flake8]: http://flake8.pycqa.org/en/latest/
[prospector]: https://prospector.landscape.io/en/master/
[pylint]: https://www.pylint.org/

## Community

- [Code of conduct](https://github.com/cprogrammer1994/ModernGL/blob/master/.github/CODE_OF_CONDUCT.md)

## Contributors

- [Szabolcs Dombi](https://github.com/cprogrammer1994)
- [SimLeek](https://github.com/SimLeek)
- [Aljenci](https://github.com/Aljenci)
- [MinchinWeb](https://github.com/MinchinWeb)
- [Silexstudio](https://github.com/Silexstudio)
- [stuaxo](https://github.com/stuaxo)
- [Tomi Aarnio](https://github.com/toaarnio)
- [Joshua Reibert](https://github.com/joshua-r)
- [Einar Forselv](https://github.com/einarf)

and [many others](https://github.com/cprogrammer1994/ModernGL/graphs/contributors)

Thank You!

Contributions are welcome. _(Please add yourself to the list)_


Metadata

Release files for moderngl 5.4.0

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 5.4.0
File Size Uploaded
moderngl-5.4.0.tar.gz 109.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for moderngl 5.4.0
File
moderngl-5.4.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
moderngl-5.4.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
moderngl-5.4.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.4.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.4.0-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
moderngl-5.4.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
moderngl-5.4.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
moderngl-5.4.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.4.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.4.0-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
moderngl-5.4.0-cp34-cp34m-macosx_10_6_intel.whl CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 3.8 MB

Release files / moderngl-5.4.0.tar.gz

Download URL moderngl-5.4.0.tar.gz
Size 109.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fdfb671c1bb31dfb8d9ea3c0c412d84cfc5f12c984311a0f90e036bffe8615a2
BLAKE2b-256 checksum
How to use checksums
0c242316f7b4aec41501cbd9bb5dbcd7bf6d9d36be2bc4c4a9076559dd7043b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp36-cp36m-win_amd64.whl

Download URL moderngl-5.4.0-cp36-cp36m-win_amd64.whl
Size 122.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d2276a9deb6d460ae6099a2ebd26516c3124bd251f8b8ea24fce278a5c3a0226
BLAKE2b-256 checksum
How to use checksums
32350f512839bca657abfdcd7da8284a2891beb479e6cacd2ef446961799e9b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp36-cp36m-win32.whl

Download URL moderngl-5.4.0-cp36-cp36m-win32.whl
Size 109.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
1d9298274ba10772b07c2f4cf88b679a9ac52bfba3113bdd30b2d48144d9bb83
BLAKE2b-256 checksum
How to use checksums
ce8a018ccbd74b12380ca722ec99d953395080a95a91811fb2e20dfbbfa63003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL moderngl-5.4.0-cp36-cp36m-manylinux1_x86_64.whl
Size 651.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
6871b0e88d4d01354afafee27f101fbd8d8b9b952ead62dd582a9db74ffc30aa
BLAKE2b-256 checksum
How to use checksums
84d5d6e2ff8e57cee155263d10f57f427985f5e0224c1caff6e07884c3fae177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp36-cp36m-manylinux1_i686.whl

Download URL moderngl-5.4.0-cp36-cp36m-manylinux1_i686.whl
Size 611.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
69be5feb40252b171136fc860f7058d4cc533cb7de1f8efc81bfe5610552e73c
BLAKE2b-256 checksum
How to use checksums
8f6a8ea1e954b875bafcc152a95c9062c2761b6924be759e85f4f3a763d80c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp36-cp36m-macosx_10_6_intel.whl

Download URL moderngl-5.4.0-cp36-cp36m-macosx_10_6_intel.whl
Size 245.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
84f13d296553aba4dddcdb23fd53e8800382136424acfd69410caec93bd0e5ed
BLAKE2b-256 checksum
How to use checksums
6c9a78b94d4f23fb84700407775a41bcaedf662f2a97ca8311c2bd03ff611373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp35-cp35m-win_amd64.whl

Download URL moderngl-5.4.0-cp35-cp35m-win_amd64.whl
Size 127.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
4d98bbaad45e23e33f6d4c4dcc8c68faf7b9b0f5dcf5cd815442d7169944dc82
BLAKE2b-256 checksum
How to use checksums
eb32ff8f0e4850ed04914cfd16abe40f45398598d2dcba96004ccaaa88367fce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp35-cp35m-win32.whl

Download URL moderngl-5.4.0-cp35-cp35m-win32.whl
Size 113.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
2c2767113b063a019c22e46e633667de936f7d726a3ac861cb5104e6892bee53
BLAKE2b-256 checksum
How to use checksums
d1d8d834b87cfad44fb9d987b095fd9c30d92c029312317762b88c2e30092e54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL moderngl-5.4.0-cp35-cp35m-manylinux1_x86_64.whl
Size 651.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8cf14c3cbbfa05f5207b6c08da1c5d53a82a5dd736ddee378e46c40f60e26ffc
BLAKE2b-256 checksum
How to use checksums
3ed9681eff95068c25231bafa5877efd2a3efdff2417802e5caced7dcb87efe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp35-cp35m-manylinux1_i686.whl

Download URL moderngl-5.4.0-cp35-cp35m-manylinux1_i686.whl
Size 611.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
3e978cac03b5c4d3793d1e04d404eaee288fbf934935e9407ec68bb0160f6d30
BLAKE2b-256 checksum
How to use checksums
924cd0bfe80dd6e45eb60b2dd715a216fe2725ccc7050ba3d01151839068a94b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp35-cp35m-macosx_10_6_intel.whl

Download URL moderngl-5.4.0-cp35-cp35m-macosx_10_6_intel.whl
Size 245.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
da042eff2e2b05491f9b2c82700267aac513f5814da406627fc94aa6f970e617
BLAKE2b-256 checksum
How to use checksums
a3c21eef65bf13cde1715e48d6764f865af423091b800fb5f8b2411834ba58e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release files / moderngl-5.4.0-cp34-cp34m-macosx_10_6_intel.whl

Download URL moderngl-5.4.0-cp34-cp34m-macosx_10_6_intel.whl
Size 245.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
872aaaa0ea6e3cc90a8d0c4504ea1933967316f175293f0dc9ec72d4ffbda61e
BLAKE2b-256 checksum
How to use checksums
89c5826d7142ba1ba91f55ae1606d5b665f1023a9afaba2d532d357c70f35fe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

Release history Release notifications | RSS feed

5.9.0

59 release files

5.8.2

50 release files

5.8.1

50 release files

5.8.0

50 release files

5.7.4

50 release files

5.7.3

50 release files

5.7.0

45 release files

5.6.4

57 release files

5.6.3

24 release files

5.5.4

19 release files

5.5.3

14 release files

5.5.2

13 release files

5.5.1

11 release files

5.4.1

14 release files

This release

5.4.0 This release

12 release files

5.3.0

12 release files

5.2.1

12 release files

5.2.0

12 release files

5.1.0

12 release files

5.0.6

12 release files

5.0.5

12 release files

5.0.3

12 release files

5.0.2

12 release files

5.0.1

11 release files

5.0.0

1 release file

4.2.1

12 release files

4.2.0

8 release files

4.1.12

5 release files

4.1.9

8 release files

4.1.8

8 release files

4.1.7

8 release files

4.1.6

8 release files

4.1.4

8 release files

4.1.3

8 release files

4.1.2

8 release files

4.1.1

8 release files

4.1.0

8 release files

4.0.0

8 release files

3.1.5

8 release files

3.1.4

6 release files

3.1.3

6 release files

3.1.2

4 release files

2.4.1

30 release files

2.4.0

19 release files

2.2.1

25 release files

2.0.9

21 release files

2.0.8

8 release files

2.0.7

5 release files

2.0.6

5 release files

2.0.5

5 release files

2.0.4

5 release files

2.0.3

5 release files

2.0.2

5 release files

0.9.4

5 release files

0.9.3

5 release files

0.9.2

5 release files

0.9.1

3 release files

0.8.8

3 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

1 release file

0.8.4

2 release files

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

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