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

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

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

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.2
File Size Uploaded
moderngl-5.4.2.tar.gz 112.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for moderngl 5.4.2
File
moderngl-5.4.2-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
moderngl-5.4.2-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
moderngl-5.4.2-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
moderngl-5.4.2-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
moderngl-5.4.2-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.4.2-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.4.2-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.2-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
moderngl-5.4.2-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
moderngl-5.4.2-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
moderngl-5.4.2-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
moderngl-5.4.2-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.2-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: 4.1 MB

Release files / moderngl-5.4.2.tar.gz

Download URL moderngl-5.4.2.tar.gz
Size 112.0 kB
Tags Source
SHA-256 checksum
How to use checksums
274a801038ab9d6f3c693fb92e2c59bf130fc8880f77d14454d8a5eba7c356b5
BLAKE2b-256 checksum
How to use checksums
c088be612f85165e6f84f2852774e80ec901f371a173c25531227a8060562403
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.2-cp37-cp37m-win_amd64.whl

Download URL moderngl-5.4.2-cp37-cp37m-win_amd64.whl
Size 123.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
20c11fe1a9dd721cbf4bb295d736215679f89ed6717020fc6dd8789c1a636763
BLAKE2b-256 checksum
How to use checksums
c1aa3b613f2cce5e00955993472d18e38e024c1db1066490aee02a5a26fa2a2b
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.2-cp37-cp37m-win32.whl

Download URL moderngl-5.4.2-cp37-cp37m-win32.whl
Size 109.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
8f88554703259a71143e1d8659d0e6785a89f526a223ebf5f6c3d00975b65eff
BLAKE2b-256 checksum
How to use checksums
bc95981efe99303098cdeb7b70c4709e17368458b4d56594a3456a86f7a2f201
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.2-cp36-cp36m-win_amd64.whl

Download URL moderngl-5.4.2-cp36-cp36m-win_amd64.whl
Size 123.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d877378637eb8ae4c8ec91ef75194ca0ce5be618360fc558f0a237a30322b2ae
BLAKE2b-256 checksum
How to use checksums
709d9e356ddabd0db8ac07c1b888248cf0cf5e6454f8a2963f2d15a798c34383
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.2-cp36-cp36m-win32.whl

Download URL moderngl-5.4.2-cp36-cp36m-win32.whl
Size 109.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
dce90681b1a8497e13740413816048c688fcdaaea5b66f855e8227e4c0a20abf
BLAKE2b-256 checksum
How to use checksums
34db0b3775fe1268471ed2f37406b4bf21fe3dc1c396d1cea0fac1a208c02068
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.2-cp36-cp36m-manylinux1_x86_64.whl

Download URL moderngl-5.4.2-cp36-cp36m-manylinux1_x86_64.whl
Size 655.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d05ad7fa3e8f7d77eab0e75ef1983e4d5ef0c3cae2818abf059850b79f7104e8
BLAKE2b-256 checksum
How to use checksums
12ceb1a17f83a11f966dfc2745d420b2b1d9c0599845676799051d9437db75aa
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.2-cp36-cp36m-manylinux1_i686.whl

Download URL moderngl-5.4.2-cp36-cp36m-manylinux1_i686.whl
Size 615.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
c7eddad679c06383f613161fabf76c911a0e88f1b7514e9534c56475ecd87d57
BLAKE2b-256 checksum
How to use checksums
5fb193828c0aabc293cc1b2807d8dbd94cb05a49025c54bac6d5541d0fef8a4a
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.2-cp36-cp36m-macosx_10_6_intel.whl

Download URL moderngl-5.4.2-cp36-cp36m-macosx_10_6_intel.whl
Size 249.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
4e5c5391db7e400776c0ebc3bbe0a9ba2257ec00f7424cfb32f42ec71a750812
BLAKE2b-256 checksum
How to use checksums
982c78a663a2957c1e00b4c63c2ede0a4c5a92002c16c6a417a615becb70831f
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.2-cp35-cp35m-win_amd64.whl

Download URL moderngl-5.4.2-cp35-cp35m-win_amd64.whl
Size 127.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
4b65fd4e51e41bf2a57915ff3972cd09b51ed0cbb0f470c1a576eac1d3106211
BLAKE2b-256 checksum
How to use checksums
a0ba9631bd736275c2021e0944a28199defc89aba9fede7653c2040273030430
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.2-cp35-cp35m-win32.whl

Download URL moderngl-5.4.2-cp35-cp35m-win32.whl
Size 114.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
0a2e6717ff641f3c374609343571c6c954fad1753a4ec94636e40b66cfd29019
BLAKE2b-256 checksum
How to use checksums
1a96b48e403f2ca9cb2c79a68ddd310482c4840dcefdd26cc9f23dda0ceb135d
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.2-cp35-cp35m-manylinux1_x86_64.whl

Download URL moderngl-5.4.2-cp35-cp35m-manylinux1_x86_64.whl
Size 655.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4772a7aff2ef70128402f58e43f885728d505362de2405df9bbe999b49eb7444
BLAKE2b-256 checksum
How to use checksums
a91f78eb5ca05005cfbf1df1ad823a8c6bd896b9a8c844902e1d77ec9ca47f1b
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.2-cp35-cp35m-manylinux1_i686.whl

Download URL moderngl-5.4.2-cp35-cp35m-manylinux1_i686.whl
Size 615.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
433d17217e6149c1dc4a825b82461f3cad465ccb945b1f27854d5daaea5d6deb
BLAKE2b-256 checksum
How to use checksums
9779599b65fc9af5ec8df1ac861cdddd114c2fa6dae90f509c31e5b16a979d4b
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.2-cp35-cp35m-macosx_10_6_intel.whl

Download URL moderngl-5.4.2-cp35-cp35m-macosx_10_6_intel.whl
Size 249.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
7f3155e6c0ecf9d3763d8b82fb21b023010047fed596ba3a63b83e196b32c633
BLAKE2b-256 checksum
How to use checksums
c8ec43d8b40e272f1c46c68ce2923234a57053a6ba06b6cac02b3ee911592977
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.2-cp34-cp34m-macosx_10_6_intel.whl

Download URL moderngl-5.4.2-cp34-cp34m-macosx_10_6_intel.whl
Size 249.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e0c43f6a831f7d57daedb60f72d680639d3848f0fd0d0ed081c8e3eac94d984f
BLAKE2b-256 checksum
How to use checksums
74694465d2732cfdbed6f05e80d5d4b96a46927c3044061ae6947324e909b9ec
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

This release

5.4.2 This release

14 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