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

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.1
File Size Uploaded
moderngl-5.4.1.tar.gz 109.6 kB Details

Built distributions (wheels)

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

Download URL moderngl-5.4.1.tar.gz
Size 109.6 kB
Tags Source
SHA-256 checksum
How to use checksums
277a1dbd8b9193531de4df2052ac4adedd18858ac5926628f1dcdc40e5fb4812
BLAKE2b-256 checksum
How to use checksums
8811ac18508d861ed0dd1e163f3b1c51a9a6ed1dba510886f681894457f5a224
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.1-cp37-cp37m-win_amd64.whl

Download URL moderngl-5.4.1-cp37-cp37m-win_amd64.whl
Size 119.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
5ede32b8d66b802573137bf7e05b251ec8b72a01e8ff72f5f715ed101b859c60
BLAKE2b-256 checksum
How to use checksums
94ecb1056a53a5f3b9e814c230dab7a75fb8b5ef6c37e843717abc3f9310538c
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.1-cp37-cp37m-win32.whl

Download URL moderngl-5.4.1-cp37-cp37m-win32.whl
Size 105.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
ad6ce61094eb0968affcec7725e831366f4b290746022a6da4e65151a30ceedf
BLAKE2b-256 checksum
How to use checksums
92eae86bc7b5cce495787395203c241709ef5ecd2bc616cb2d065b5a7e49ba66
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.1-cp36-cp36m-win_amd64.whl

Download URL moderngl-5.4.1-cp36-cp36m-win_amd64.whl
Size 122.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8226de2475d134d203554c0366155fed553392bae661376705d7cf471eb35c12
BLAKE2b-256 checksum
How to use checksums
95361c5485215c53f7a892b40bc1af69f288dac3be9efcbe3f9a81970d0058f9
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.1-cp36-cp36m-win32.whl

Download URL moderngl-5.4.1-cp36-cp36m-win32.whl
Size 109.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
2bd497d872d998e9bd5766932f03393d4414ca7940d6d3cf604d84a892bb8d10
BLAKE2b-256 checksum
How to use checksums
7ca362a875f599a10ffb13bd91e7e7ec54b31366aa37846a03b26aa3a2b30c59
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.1-cp36-cp36m-manylinux1_x86_64.whl

Download URL moderngl-5.4.1-cp36-cp36m-manylinux1_x86_64.whl
Size 651.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
bd688091d53108a914a0e615450b3ebfc9bfb18e06f86c370f0e129c6b828c22
BLAKE2b-256 checksum
How to use checksums
de8074417bd4598f947c606028bcbcccde77011fb7159bc00b49f809bd32fec5
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.1-cp36-cp36m-manylinux1_i686.whl

Download URL moderngl-5.4.1-cp36-cp36m-manylinux1_i686.whl
Size 611.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
213cde4be084c8f287619d58b30e5c34b6fdb9174cdc8d97344d1fda4f870090
BLAKE2b-256 checksum
How to use checksums
45ccfc24fbb8e57e9f2976a57f08c1394a02204644cc58234f99353bfbd6a103
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.1-cp36-cp36m-macosx_10_6_intel.whl

Download URL moderngl-5.4.1-cp36-cp36m-macosx_10_6_intel.whl
Size 245.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e6f1bccf888da9765826bbbe33edb3caa3e80938a37e1c08d02ae14cad84fb46
BLAKE2b-256 checksum
How to use checksums
bd4a59a2abdbeab7ca13e2bc2340f452725be394c2b56b088590397ac866bb82
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.1-cp35-cp35m-win_amd64.whl

Download URL moderngl-5.4.1-cp35-cp35m-win_amd64.whl
Size 127.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
2f77406232d52740e487092812a4bdbe145e4d6e05c03c815f65eb73ba8a6d44
BLAKE2b-256 checksum
How to use checksums
a8018f03857c36520b2736bd4fa03442e7f7b46a1a0ba3eef3264ee99d247015
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.1-cp35-cp35m-win32.whl

Download URL moderngl-5.4.1-cp35-cp35m-win32.whl
Size 113.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
f6464bf2300275ab54695075a34caf1d83bf808bb19ee203ef193c56770f7573
BLAKE2b-256 checksum
How to use checksums
a31a1fe3b0dad0a2703679e7bcd3c0bc913088a3e4bbab7100c52a278c7b7166
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.1-cp35-cp35m-manylinux1_x86_64.whl

Download URL moderngl-5.4.1-cp35-cp35m-manylinux1_x86_64.whl
Size 651.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c28298de9580be3414ca54e04cfe6d7dd7162ec660c94d1fdbf2d849d6576f97
BLAKE2b-256 checksum
How to use checksums
3fde5a6d42bd07e4e60d047ffafb70a724ec38c6e8d498ec70b1ea5213cc7523
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.1-cp35-cp35m-manylinux1_i686.whl

Download URL moderngl-5.4.1-cp35-cp35m-manylinux1_i686.whl
Size 611.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
05352d310ded51165e4af98a225badba6e696e850c07705821b2fa0b15c4e150
BLAKE2b-256 checksum
How to use checksums
f2ffabb9320cc585ad16c08d78c83f33fcea64532b53aedca60fdc4a58a1a589
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.1-cp35-cp35m-macosx_10_6_intel.whl

Download URL moderngl-5.4.1-cp35-cp35m-macosx_10_6_intel.whl
Size 245.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
6a98d4b1a6207b500919d68924ea6496202c91ff67f82d62b4d3e7a5f599bcce
BLAKE2b-256 checksum
How to use checksums
5a40ce6c5d405531d5b9912358d9c531b2a378e42b8f4c60ea06b340318c5842
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.1-cp34-cp34m-macosx_10_6_intel.whl

Download URL moderngl-5.4.1-cp34-cp34m-macosx_10_6_intel.whl
Size 245.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
5cd668fedef590ba407db7ba0f114a250dc1bddfef0e696bf484e8b303a72a1b
BLAKE2b-256 checksum
How to use checksums
beab8d543fe2e4bed10018d4fba8f993cd50767b05fb8e117881e0e6b7ba13cd
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.1 This release

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