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.3.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.3.0
File Size Uploaded
moderngl-5.3.0.tar.gz 100.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for moderngl 5.3.0
File
moderngl-5.3.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
moderngl-5.3.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
moderngl-5.3.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.3.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.3.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.3.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
moderngl-5.3.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
moderngl-5.3.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.3.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.3.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.3.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.6 MB

Release files / moderngl-5.3.0.tar.gz

Download URL moderngl-5.3.0.tar.gz
Size 100.5 kB
Tags Source
SHA-256 checksum
How to use checksums
27d8f791cae4d69ffc5b8c640ad7180e18690a49c0abf5ee3f280d346cd9a7b9
BLAKE2b-256 checksum
How to use checksums
93ecc267f7422f491e94906d5e4fb9f7df737b12a814dea605ee55472c86f756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp36-cp36m-win_amd64.whl
Size 104.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
825c5ee7ee58cefa058e466356f3c07af5b722ae6174f17ad2ad100addb247c7
BLAKE2b-256 checksum
How to use checksums
a3df8a40749bc46a2b3e3171c1c2d6ae21181f3a154959fd0466774d0f58be3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp36-cp36m-win32.whl
Size 135.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
369d3766609a091ce3ca66e0273d746f4ad678c05d158d7df75b7706937a3e27
BLAKE2b-256 checksum
How to use checksums
cfb6a24865641d3bcfcaad786745fd071d544c6670e74401d2c748bffe105c4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp36-cp36m-manylinux1_x86_64.whl
Size 604.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
5391dab550e6c6554d6373d83899d6f02650c37bf41944ae2a8c5ce7d4aa283b
BLAKE2b-256 checksum
How to use checksums
8a786f281b197751bc223f9d41524a4963f1671f8ebe692ca6b7458c3c34df0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp36-cp36m-manylinux1_i686.whl
Size 567.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
b3a35893f1cf07af01848af033ce76ba0bd2c805ab8d52cfe848d866e563c719
BLAKE2b-256 checksum
How to use checksums
360244439a79592ca9d0db5ad2fc674126c34820274e5c5adb7903ef7479bf97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp36-cp36m-macosx_10_6_intel.whl
Size 222.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e0627ca9a51cfd5e83596696904e289fd76c32ab0f780378f28233bd905c7211
BLAKE2b-256 checksum
How to use checksums
fea90e333cea4e92b71e7de6645707a57c6bb86162f7ec1fe5a4c211fbdea69d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp35-cp35m-win_amd64.whl
Size 108.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
eb1e0ad0b53389371595e61888a7d54d95a51f6ba5c9b24fb27ce760179c627c
BLAKE2b-256 checksum
How to use checksums
fa59601cac2f8828a185f5db125ef40b88bdbb7f0d92f01ca4a08e5b16fefb75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp35-cp35m-win32.whl
Size 95.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
57684fb234f31b16ba80df6fbc59b103bf79abac4bfca4257b95d6091272f5d8
BLAKE2b-256 checksum
How to use checksums
b55c70f46fd234437ade9109c5f121da951ab2a12b6fa35803fc2d6a37b9678a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp35-cp35m-manylinux1_x86_64.whl
Size 604.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c45d7a9cea53500884ff62fa5e4ba1a8ec27c630dede2961a2873aa895836e43
BLAKE2b-256 checksum
How to use checksums
bc36c25cb7481393007d5e97308ea0d5b2e33eb2dc2d0c59732be7c7f1bbf717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp35-cp35m-manylinux1_i686.whl
Size 567.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
539c609d9d49bfb7268cb0ccca12f6e7ddcb5d7b02b0cff6f643cc438b17de43
BLAKE2b-256 checksum
How to use checksums
017a94b79403f7a662098be2705ebab33a2b167683a9233d922b6463c177d1c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp35-cp35m-macosx_10_6_intel.whl
Size 222.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
3f125b16967f70da24471cf389ed722ccb01d358802fc615325f72fff4759420
BLAKE2b-256 checksum
How to use checksums
39ce540775d467b56d8b34665c5283ed2644be12c1d43eeb6b9d005e31560acb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL moderngl-5.3.0-cp34-cp34m-macosx_10_6_intel.whl
Size 222.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
78e8f887fbe54f37147421826d8d2240227a29e48a8bf6038f438711fda3a373
BLAKE2b-256 checksum
How to use checksums
ee8b1248ec3516bc6027338b9e932858ba968f11d654f02834609f727877dda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

5.4.0

12 release files

This release

5.3.0 This release

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