skillfed

moderngl

ModernGL: High performance rendering for Python 3

moderngl v5.12.0 597.9K downloads/30d#5,835 on PyPI2,317
Permissive license MIT Active released

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 moderngl

uv

uv add moderngl

poetry

poetry add moderngl

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI ApprovedLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyTopic :: Games/EntertainmentTopic :: Multimedia :: GraphicsTopic :: Multimedia :: Graphics :: 3D RenderingTopic :: Scientific/Engineering :: Visualization

Tags

opengl python wrappergpu graphics renderingshader programming python3d graphics libraryglsl shader executionhigh performance graphicsheadless opengl rendering
gpu-renderingshader-programmingheadless-graphics

More Graphics packages