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, but we provide a utility library moderngl_window making window creation and resource loading very simple.

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

pip install -r tests/requirements.txt
pytest tests

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

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.3
File Size Uploaded Provenance Actions
moderngl-5.5.3.tar.gz 115.3 kB Without provenance Details for moderngl-5.5.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for moderngl 5.5.3
File Actions
moderngl-5.5.3-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details for moderngl-5.5.3-cp37-cp37m-win_amd64.whl
moderngl-5.5.3-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details for moderngl-5.5.3-cp37-cp37m-win32.whl
moderngl-5.5.3-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details for moderngl-5.5.3-cp37-cp37m-manylinux1_x86_64.whl
moderngl-5.5.3-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details for moderngl-5.5.3-cp37-cp37m-manylinux1_i686.whl
moderngl-5.5.3-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details for moderngl-5.5.3-cp37-cp37m-macosx_10_9_x86_64.whl
moderngl-5.5.3-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details for moderngl-5.5.3-cp36-cp36m-win_amd64.whl
moderngl-5.5.3-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details for moderngl-5.5.3-cp36-cp36m-win32.whl
moderngl-5.5.3-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details for moderngl-5.5.3-cp36-cp36m-manylinux1_x86_64.whl
moderngl-5.5.3-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details for moderngl-5.5.3-cp36-cp36m-manylinux1_i686.whl
moderngl-5.5.3-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details for moderngl-5.5.3-cp36-cp36m-macosx_10_9_x86_64.whl
moderngl-5.5.3-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details for moderngl-5.5.3-cp35-cp35m-manylinux1_x86_64.whl
moderngl-5.5.3-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details for moderngl-5.5.3-cp35-cp35m-manylinux1_i686.whl
moderngl-5.5.3-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details for moderngl-5.5.3-cp35-cp35m-macosx_10_6_intel.whl

Total release size: 5.2 MB

Release files / moderngl-5.5.3.tar.gz

Download URL moderngl-5.5.3.tar.gz
Size 115.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eab923914ac051bf136e8d7c19dcb8fe556ab8a1182fb1d92ba67ffabc705ecc
BLAKE2b-256 checksum
How to use checksums
553cd95c09c7ca3b64c4c72b709ea90f7944137b255218f705ea615bbff7283e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

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

Download URL moderngl-5.5.3-cp37-cp37m-win_amd64.whl
Size 133.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0c3ff0e1185125410791676d49f53a358a9246a382301850ad9e5812abb6c18a
BLAKE2b-256 checksum
How to use checksums
64302374d18849bfd8185308b0b5f93e3d504eea4436801aaa7f744d3ea0c9ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

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

Download URL moderngl-5.5.3-cp37-cp37m-win32.whl
Size 114.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
864492b6028baf8e993b40257a294abf8c1595aad287a1928b7de77555ee3462
BLAKE2b-256 checksum
How to use checksums
04f129e72f7a5ae57a8f698a74f297c177b8eebdfc333f833ea4ec4198803cd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

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

Download URL moderngl-5.5.3-cp37-cp37m-manylinux1_x86_64.whl
Size 674.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b45881d0b4e3454fa7b84bf522bbbe1810cc19072bdb1a992b4ae1c486a017c6
BLAKE2b-256 checksum
How to use checksums
ae24fde65bb7581567bc7d21ad49b75243ac1e3d0ad6104a4390482704568d96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Release files / moderngl-5.5.3-cp37-cp37m-manylinux1_i686.whl

Download URL moderngl-5.5.3-cp37-cp37m-manylinux1_i686.whl
Size 654.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
03eeb6dc4f13f1148b06f11ac60d58705ab6e7648139483001f994ee2aba99f8
BLAKE2b-256 checksum
How to use checksums
fbe9018c1c44123b1406fab4f059b778d8f34d2229c06699ad0da19618c54d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Release files / moderngl-5.5.3-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL moderngl-5.5.3-cp37-cp37m-macosx_10_9_x86_64.whl
Size 198.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c068210b4fa8e1648b96f26b2196717fc5883625595057dc37a3a0b4514c882b
BLAKE2b-256 checksum
How to use checksums
223ef2d76c888e056138efc22fa82e8d2ca8952f05d41e4e90b5be042d8ec718
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.3-cp36-cp36m-win_amd64.whl

Download URL moderngl-5.5.3-cp36-cp36m-win_amd64.whl
Size 133.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
4d633766c5708421500c0004143886c8dfdd1a3f6d5f14f3400c6c26060136b3
BLAKE2b-256 checksum
How to use checksums
68bd7cce66ebe264ec63e92d0bf346e03324416199b23287088305f3cbf4a20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

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

Download URL moderngl-5.5.3-cp36-cp36m-win32.whl
Size 114.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
a1bee80df4006c1831b90b486670caee76b72806bef712a342b6be906f624405
BLAKE2b-256 checksum
How to use checksums
f539bca51aaa612104d385bb094b3c71290fab37e42263c5d418d210cbba04a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

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

Download URL moderngl-5.5.3-cp36-cp36m-manylinux1_x86_64.whl
Size 674.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
f10afe5744c20831e7172ddf3fd22f16229a2c2ba585c22216642e66b8390003
BLAKE2b-256 checksum
How to use checksums
24c0dc6af2bb8f22a9e39ac8e5cbbde3aa74b0668cfc6123880e548befc6f65f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

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

Download URL moderngl-5.5.3-cp36-cp36m-manylinux1_i686.whl
Size 654.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
320fc9c795e71027844427b4d2310a63b2c8e9ecd9f0f74ff8c46fea749babc6
BLAKE2b-256 checksum
How to use checksums
8d129f5342f0bb26e11c8ee37debc331354363af6bef2b15843ef1a4be6ce840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Release files / moderngl-5.5.3-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL moderngl-5.5.3-cp36-cp36m-macosx_10_9_x86_64.whl
Size 149.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
dff879ebe482476210597fe8e824b8d841cd60be7fe9e8484d39583b9be51496
BLAKE2b-256 checksum
How to use checksums
8d88b87f384c28555d824093ea61a6cff08a170fa9262c647efd9e561972b118
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.3-cp35-cp35m-manylinux1_x86_64.whl

Download URL moderngl-5.5.3-cp35-cp35m-manylinux1_x86_64.whl
Size 674.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
e9f3a3ac4e58569100381e9ebe0f6df4f94d1c73642645905c99e136d6bab1e7
BLAKE2b-256 checksum
How to use checksums
77b2c830ad5058ef5beaf95aecff68d77129c015863acd774885d0bf62092f7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

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

Download URL moderngl-5.5.3-cp35-cp35m-manylinux1_i686.whl
Size 654.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
abf97bdf5938a1c9f7bd21c184a492058aaf37f66908130451e7c3086a1889dc
BLAKE2b-256 checksum
How to use checksums
9995a2fbe2ac7c708b773f75e15ef0ee5f491a98fd6c546d6b0af9cfbcebe5b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

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

Download URL moderngl-5.5.3-cp35-cp35m-macosx_10_6_intel.whl
Size 235.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
271bffd260e07e92c2063242225f6e318ecdbcc5c0540624feef97228de33094
BLAKE2b-256 checksum
How to use checksums
044f47e668493b899630e9ca4c7d90eb7289e5c1a9f7af92b7ca0e17d4bcb2e8
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

Security for moderngl 5.5.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.5.3 This release

14 release files No provenance

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