moderngl
ModernGL: High performance rendering for Python 3
What it is and what it does
ModernGL is a C++-backed Python binding for OpenGL Core that abstracts away the verbose OpenGL API into a cleaner, more Pythonic interface. Instead of writing multiple OpenGL function calls to perform a single task (like creating a vertex buffer), you write one or two lines of ModernGL code. It handles GPU memory allocation, shader compilation, texture binding, and render calls with minimal ceremony.
The library is designed for graphics applications—games, scientific simulations, data visualizations, and interactive user interfaces. It supports rendering with or without a window (headless mode via glcontext), integrates naturally with NumPy arrays and Pillow images, and implements GLSL shader programming for vertex, fragment, geometry, tessellation, and compute shaders. The trade-off is that you need an OpenGL 3.3+ capable system and must understand shader programming to use it effectively.
Use it for:
- Build interactive 3D scientific visualizations or simulations that need GPU acceleration without learning raw OpenGL
- Render graphics in headless environments (servers, CI/CD) where no display is available
- Create game engines or graphics demos with less boilerplate than PyOpenGL
- Process large datasets on the GPU using compute shaders for post-processing or physics simulation
- Prototype shader-based effects (lighting, particles, post-processing) quickly in Python
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ModernGL is a Python wrapper over OpenGL Core that simplifies GPU-accelerated graphics rendering by providing a Pythonic API for creating shaders, buffers, textures, and render passes with less boilerplate than raw OpenGL.
Yes, if you need GPU-accelerated graphics in Python and are willing to learn shader programming. ModernGL is actively maintained, has no known vulnerabilities, and significantly reduces OpenGL boilerplate. Install friction is moderate but manageable on common platforms. Not suitable if you need a higher-level graphics abstraction or cannot meet the OpenGL 3.3+ requirement.
Install
moderngl on PyPI
pip
pip install moderngluv
uv add modernglpoetry
poetry add modernglInstalling moderngl
Before you install
Medium install friction due to compiled C++ bindings and OpenGL system dependency, but wheels are available for common platforms (macOS, Linux, Windows, multiple architectures). Maintenance is active with recent commits and stable production status.
License in practice
MIT license is permissive; you can use, modify, and distribute ModernGL in commercial and private projects without restriction, though you must include the license notice.
Quickstart
pip install moderngl
import moderngl
ctx = moderngl.get_context()
buf = ctx.buffer(b"Hello World!")
print(buf.read())
Requires OpenGL 3.3 or later; some features need OpenGL 4.3. System must have a working OpenGL driver or use glcontext extra for headless rendering.
Verify before relying
- Whether pre-built wheels cover all target deployment platforms and architectures
- Performance comparison claims relative to PyOpenGL in real-world scenarios
- Specific OpenGL extension support and coverage beyond core 3.3/4.3
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — glcontext |
| Maintenance | actively maintained — 666 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 597,880/month — #5,835 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: moderngl-5.12.0-cp310-cp310-macosx_10_9_x86_64.whl; moderngl-5.12.0-cp310-cp310-macosx_11_0_arm64.whl; moderngl-5.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; moderngl-5.12.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; moderngl-5.12.0-cp310-cp310-musllinux_1_2_i686.whl; moderngl-5.12.0-cp310-cp310-musllinux_1_2_x86_64.whl; moderngl-5.12.0-cp310-cp310-win32.whl; moderngl-5.12.0-cp310-cp310-win_amd64.whl; moderngl-5.12.0-cp311-cp311-macosx_10_9_x86_64.whl; moderngl-5.12.0-cp311-cp311-macosx_11_0_arm64.whl; moderngl-5.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; moderngl-5.12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; moderngl-5.12.0-cp311-cp311-musllinux_1_2_i686.whl; moderngl-5.12.0-cp311-cp311-musllinux_1_2_x86_64.whl; moderngl-5.12.0-cp311-cp311-win32.whl; moderngl-5.12.0-cp311-cp311-win_amd64.whl; moderngl-5.12.0-cp312-cp312-macosx_10_13_x86_64.whl; moderngl-5.12.0-cp312-cp312-macosx_11_0_arm64.whl; moderngl-5.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; moderngl-5.12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Keywords: ModernGL, OpenGL, PyOpenGL, rendering, graphics, shader, GLSL, GPU, visualization, 2D, 3D
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
glcontextProvides portable OpenGL context creation…
permissive · top 15,000 on PyPI
moderngl-windowmoderngl-window simplifies OpenGL window…
permissive · top 15,000 on PyPI
vispyVisPy is a GPU-accelerated 2D/3D visualization…
permissive · top 5,000 on PyPI
wgpuwgpu-py provides a Python binding to WebGPU, a…
permissive · top 15,000 on PyPI
PyOpenGLPyOpenGL provides standard OpenGL bindings for…
permissive · top 5,000 on PyPI
PyOpenGL-accelerateProvides Cython-compiled C extensions that…
permissive · top 5,000 on PyPI
panda3d-simplepbrProvides a physically-based rendering (PBR)…
permissive · top 15,000 on PyPI
comfy-anglePackages redistributable ANGLE graphics…
permissive · top 5,000 on PyPI
pyglmPyGLM provides Python bindings to OpenGL…
permissive · top 15,000 on PyPI
Panda3DPanda3D is a 3D game engine with Python…
permissive · top 15,000 on PyPI