Skip to main content

preview

ModernGL

pip install 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

>>> 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.

Easy to use with Pillow and Numpy

>>> img = Image.open('texture.jpg')
>>> ctx.texture(img.size, 3, img.tobytes())
<Texture: 1>
>>> ctx.buffer(np.array([0.0, 0.0, 1.0, 1.0], dtype='f4'))
<Buffer: 1>

Compared to PyOpenGL

With PyOpenGL, using the original OpenGL API, you have to write three lines to achieve a simple task like binding a VBO:

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)

With ModernGL you need just one simple line per VBO to achieve the same results:

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

Build

build build

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.

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.

Limitations using ModernGL over PyOpenGL?

All the necessary 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 or raise a PR.

Supported platforms

  • Windows
  • Linux
  • Mac

Installing from source

Installing on Ubuntu from source

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

Building the sphinx documentation

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

Running tests

pytest

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

Headless rendering

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

Community

Contributors

and many others

Thank You!

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

Metadata

Release files for moderngl 5.5.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.5.0
File Size Uploaded
moderngl-5.5.0.tar.gz 112.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for moderngl 5.5.0
File
moderngl-5.5.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
moderngl-5.5.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
moderngl-5.5.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.5.0-cp37-cp37m-macosx_10_6_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
moderngl-5.5.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
moderngl-5.5.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
moderngl-5.5.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.5.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.5.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
moderngl-5.5.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
moderngl-5.5.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.5.0-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 3.7 MB

Release files / moderngl-5.5.0.tar.gz

Download URL moderngl-5.5.0.tar.gz
Size 112.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04770ad904c803e7fbcc217a4293a4b1d65b32a9976996b83c77f93f185d1d75
BLAKE2b-256 checksum
How to use checksums
5eacfefe533ec3455f8b40a1c4e16371d88f1bbf899e7d53a82fc943d69e9731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

Release files / moderngl-5.5.0-cp37-cp37m-win_amd64.whl

Download URL moderngl-5.5.0-cp37-cp37m-win_amd64.whl
Size 133.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
9deb4dc7fe5480c9111baca0029cfa7db951969c0b6d81308fd19968ced5bc74
BLAKE2b-256 checksum
How to use checksums
0e07b914b4cc2fdde15b8e6c708a0335be70a3c7b4eb12868644d5b61766c52e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

Release files / moderngl-5.5.0-cp37-cp37m-win32.whl

Download URL moderngl-5.5.0-cp37-cp37m-win32.whl
Size 118.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
4d49e0656a70723d9c0fd5d5debf7f74ea503556e02670869037c3968f61ba35
BLAKE2b-256 checksum
How to use checksums
688a193b79d5b3e9410844d6c3f11506c0dde81db8ba192b2369ee4fcac2562e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

Release files / moderngl-5.5.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL moderngl-5.5.0-cp37-cp37m-manylinux1_x86_64.whl
Size 691.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
04297332a03455c70b6eb92bc0fbd16c257506b959542d088614c9cee0e220a2
BLAKE2b-256 checksum
How to use checksums
cb2e3e2c15a28236b510e342bbabbbe42cd4594596879a4e888901c875e26216
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

Release files / moderngl-5.5.0-cp37-cp37m-macosx_10_6_intel.whl

Download URL moderngl-5.5.0-cp37-cp37m-macosx_10_6_intel.whl
Size 241.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
4ee081bbc5c83edaae58a4569003c288ad52385926d6b4ae7fd3c8c1e1b74d3c
BLAKE2b-256 checksum
How to use checksums
8eb28308fbef65b113acc8a177b6048e5fb505443c61096c4d0a46c8f4b7029a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.8

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

Download URL moderngl-5.5.0-cp36-cp36m-win_amd64.whl
Size 123.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
9eba52a87ba04e4db087b4999a6ee2767ad6ee9393744641abb51bce58fb1db8
BLAKE2b-256 checksum
How to use checksums
e782562d5ceb5a6b4860876d75a9001bd5a25e4f31e7463b0414d03bca1596e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp36-cp36m-win32.whl
Size 111.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
45e3b397095858682fb430a49827e148868ae457b49cb818847f35ff0a361afa
BLAKE2b-256 checksum
How to use checksums
ed37e3355935e1613edc4fdb9d0f6c05e473a1d6831f2afaa1c043bdb19620dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp36-cp36m-manylinux1_x86_64.whl
Size 691.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
de488db26150d5abd8173fde1edc314ea1a116364bad0acc08ab09499fb90b60
BLAKE2b-256 checksum
How to use checksums
fb9d85c6e9895abe857002edc9bfd1587610636e9f0d71ab8ba61a16d6cf5225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp36-cp36m-macosx_10_6_intel.whl
Size 242.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
f167125e5a9752f951debae8e51d29d8afd31a774289e61f90b2a804943c79f5
BLAKE2b-256 checksum
How to use checksums
d1546f9dd75748d30bcc780bfe51eb89b7e2dc65b4dee06148e8610269553a62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.8

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

Download URL moderngl-5.5.0-cp35-cp35m-win_amd64.whl
Size 133.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
9cb56290e92c4ddf71c6c689450ef9f58bfd9c051dd4532872fe2abbaa387fbb
BLAKE2b-256 checksum
How to use checksums
4bcef5bcef2c52d9d1154d360bece0270b2d95ac1c6c658529ba4046834876a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp35-cp35m-win32.whl
Size 118.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
6dca3b94ab3d695639eef97215422df43671e458619a9ca1cacbe3dcf5fba226
BLAKE2b-256 checksum
How to use checksums
fb9b8b2bf6607aeb283a32cb97d2ccb1e967b3164ee2c7f0bb1891215bae76ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp35-cp35m-manylinux1_x86_64.whl
Size 691.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
f60b0b9fcbf8d16e30e6e82ba97d851601957f56d7dd8712ef4ef01994642a22
BLAKE2b-256 checksum
How to use checksums
eb9068ae759fa940fd300c109e4a315c2dfeb1df6ba6936222e3155b425c6c89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

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

Download URL moderngl-5.5.0-cp35-cp35m-macosx_10_6_intel.whl
Size 241.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
7273314d64974c8a3b4582588541a0d105d174dfe1289e0f51cffbf62a0b5ac8
BLAKE2b-256 checksum
How to use checksums
47b02e624079a9d25b4789eb080d598a65746923f55b20a460b02b2d4cf6daab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.8

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

This release

5.5.0 This release

13 release files

5.4.1

14 release files

5.4.0

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