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.

We currently have example windows you can use or look at in the standard example system currently supporting PyQt5, GLFW, SDL2 and Pyglet (1.x).

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.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.5.2
File Size Uploaded
moderngl-5.5.2.tar.gz 180.8 kB Details

Built distributions (wheels)

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

Total release size: 8.7 MB

Release files / moderngl-5.5.2.tar.gz

Download URL moderngl-5.5.2.tar.gz
Size 180.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5f1eb514efa07d8c39c63ecea9022b4347e776b7ef85c522bc19dfd153c6e152
BLAKE2b-256 checksum
How to use checksums
49ea97f75d1da585e6a0180403b96dbe2afc8b0bbfd49eb8812a303b43defca7
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp37-cp37m-win_amd64.whl
Size 186.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c2c43f03a7dd5191eb3ccdbda9abc4f293561da91af082ecd04e60e60f77f266
BLAKE2b-256 checksum
How to use checksums
4747f03cbe1feb9df9184afbe4b97af504d2ca8b4497ef05d63318d8f1e9575f
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp37-cp37m-win32.whl
Size 157.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
c509e7600371b68fe364fc2e7194d63577c5e92d62e3c1e4d7485eded14aabde
BLAKE2b-256 checksum
How to use checksums
2573e6cdac0aa3f19918d936c4ca1b1e719736a85e411ffd289e1354ef33a018
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp37-cp37m-manylinux1_x86_64.whl
Size 1.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
51e67b48daa03d28942bec3adf4647904340490eb2dc25340d8be6d68ff4ec60
BLAKE2b-256 checksum
How to use checksums
a3783c7a327b53fba44c3ae281cfd0868af1819ee041ebbfe4b77a9daf3b4dab
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp37-cp37m-manylinux1_i686.whl
Size 1.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
3da263f56ee133bdf0e52987a4f71dba87185943bbfae76f122edcef719c368f
BLAKE2b-256 checksum
How to use checksums
a15afda2988f2eb176be102274f6e6b4f75739943877a5f2472d034c88243c08
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp37-cp37m-macosx_10_9_x86_64.whl
Size 201.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e482f296566c56c8f284af0572d75dd60329f3743a913e7557bf31750605de89
BLAKE2b-256 checksum
How to use checksums
2168a77645aa5db0c1cb893be9b31ecdd59b4f5ad2cff6b71d60d275eecd473e
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.2-cp36-cp36m-win_amd64.whl

Download URL moderngl-5.5.2-cp36-cp36m-win_amd64.whl
Size 186.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
901a388d04acd3524944695da1014abbb4f6f65426e0fc1a50fd1de2fdc66775
BLAKE2b-256 checksum
How to use checksums
2b8d385a89361ccce9e15e87e5218619745f87a7a2cbb0003d0da3300ada15eb
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp36-cp36m-win32.whl
Size 157.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
48ce45eba83cfa500120e0f9d12cc968661d78e38753b8a98c5f4966cb3dfc26
BLAKE2b-256 checksum
How to use checksums
0e3b464af5ac3cc7abf520d2ecc625c61bcbbab7be6a887b4158d5f93c454957
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp36-cp36m-manylinux1_x86_64.whl
Size 1.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
63eda028dba735120767e233a647acf9771e2c5a0d31e8391388917056a1a991
BLAKE2b-256 checksum
How to use checksums
4215b60d03508536713873890c0643e094358a0361308214f1039b87fa23a927
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp36-cp36m-manylinux1_i686.whl
Size 1.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
ac413997ca4284f6d1b727e1c97894b8605f4ac674f2822a4fb32f1e9bdc23d4
BLAKE2b-256 checksum
How to use checksums
695aa05ff96e1d5b895e7d5dd858f09577cd1208008c51ed5b873ca287655bab
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp36-cp36m-macosx_10_9_x86_64.whl
Size 201.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5ac07f325ace21b937d0fba3cb4727c9062ea6552ee18ec05dc8d62667310652
BLAKE2b-256 checksum
How to use checksums
70aad2f6b16e18bacd5394557716838b206dadb2270365877aa15667c836602c
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.2-cp35-cp35m-manylinux1_x86_64.whl

Download URL moderngl-5.5.2-cp35-cp35m-manylinux1_x86_64.whl
Size 1.3 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
cfa2debbbdde1eb83916ad60d10d5da55629ad8f6100f6683bd10a40146e5cf0
BLAKE2b-256 checksum
How to use checksums
22aecdc26c2f8a86bb43804dbf781d412ab5b800a4c30725bb69ad5dfa8e26d1
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.1 CPython/3.7.3

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

Download URL moderngl-5.5.2-cp35-cp35m-manylinux1_i686.whl
Size 1.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
ad1996fb8328758eafdfec701e56a1185ffe4c196d20c851538e98a6738a0186
BLAKE2b-256 checksum
How to use checksums
50b37a0304d86c6ca5d7377df57ca918ae310868ebe4d9b6c93d03cfccd42d24
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.1 CPython/3.7.3

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

This release

5.5.2 This release

13 release files

5.5.1

11 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