Skip to main content

ModernGL: High performance rendering for Python 3

Project description

ModernGL
========

.. code-block:: sh

pip install ModernGL


* `Documentation <https://moderngl.readthedocs.io/>`_
* `Examples <https://github.com/cprogrammer1994/ModernGL/tree/master/examples/#readme>`_
* `ModernGL on Github <https://github.com/cprogrammer1994/ModernGL/>`_
* `ModernGL on PyPI <https://pypi.python.org/pypi/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
------------

.. code-block:: py

>>> 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 <https://github.com/cprogrammer1994/ModernGL/tree/master/examples/#readme>`_.

Easy to use with Pillow and Numpy
---------------------------------

.. code-block:: py

>>> img = Image.open('texture.jpg')
>>> ctx.texture(img.size, 3, img.tobytes())
<Texture: 1>

.. code-block:: py

>>> 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
~~~~~~~~~~~~~~

.. code-block:: py

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
~~~~~~~~~~~~~~

.. code-block:: py

vbo1 = ctx.buffer(b'Hello World!')
vbo2 = ctx.buffer(reserve=1024, dynamic=True)

Build
-----

.. image:: https://img.shields.io/travis/cprogrammer1994/ModernGL/master.svg?label=build
:target: https://travis-ci.org/cprogrammer1994/ModernGL
:alt: build


.. image:: https://img.shields.io/appveyor/ci/cprogrammer1994/ModernGL/master.svg?label=build
:target: https://ci.appveyor.com/project/cprogrammer1994/ModernGL
:alt: build


.. code-block:: sh

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 <https://github.com/cprogrammer1994/ModernGL/tree/master/examples/standalone>`_ 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 <https://pypi.python.org/pypi/PyQt5/>`_\ , `pyglet <https://bitbucket.org/pyglet/pyglet/wiki/Home>`_\ ,
`pygame <https://www.pygame.org/news>`_\ , `GLUT <https://wiki.python.org/moin/PyOpenGL>`_ 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 <https://github.com/cprogrammer1994/ModernGL/issues>`_ or raise
a `PR <https://github.com/cprogrammer1994/ModernGL/pulls>`_.

Supported platforms
-------------------

* [x] Windows
* [x] Linux
* [x] Mac

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moderngl-5.1.0.tar.gz (99.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

moderngl-5.1.0-cp36-cp36m-win_amd64.whl (102.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

moderngl-5.1.0-cp36-cp36m-win32.whl (89.8 kB view details)

Uploaded CPython 3.6mWindows x86

moderngl-5.1.0-cp36-cp36m-manylinux1_x86_64.whl (602.4 kB view details)

Uploaded CPython 3.6m

moderngl-5.1.0-cp36-cp36m-manylinux1_i686.whl (565.3 kB view details)

Uploaded CPython 3.6m

moderngl-5.1.0-cp36-cp36m-macosx_10_6_intel.whl (219.9 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

moderngl-5.1.0-cp35-cp35m-win_amd64.whl (107.2 kB view details)

Uploaded CPython 3.5mWindows x86-64

moderngl-5.1.0-cp35-cp35m-win32.whl (94.2 kB view details)

Uploaded CPython 3.5mWindows x86

moderngl-5.1.0-cp35-cp35m-manylinux1_x86_64.whl (602.6 kB view details)

Uploaded CPython 3.5m

moderngl-5.1.0-cp35-cp35m-manylinux1_i686.whl (565.4 kB view details)

Uploaded CPython 3.5m

moderngl-5.1.0-cp35-cp35m-macosx_10_6_intel.whl (219.9 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

moderngl-5.1.0-cp34-cp34m-macosx_10_6_intel.whl (219.9 kB view details)

Uploaded CPython 3.4mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file moderngl-5.1.0.tar.gz.

File metadata

  • Download URL: moderngl-5.1.0.tar.gz
  • Upload date:
  • Size: 99.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for moderngl-5.1.0.tar.gz
Algorithm Hash digest
SHA256 9ae60e00784ad7f225f897df6a281b66799e083a33360af7f3766e0afa63ab20
MD5 4ee490b86842ef446d910a0681c7b7c2
BLAKE2b-256 895c8d1eed262a51a2e4b0b7868f40476e275e49ff64e9c9b0b4414ce9a59e29

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a039da60780eba15d073bbd04e1142b48fa6549bef26f93a46470654bd91c629
MD5 23a9f4871dd38cbba2e87af11fff5133
BLAKE2b-256 4d3389001231e268f281a155aff2c708b583739b87a698964043e517c52f2534

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 d1f31d01ffb8edd22709c20635e0ee5b546f80092f6f7a31348cffcfbc140617
MD5 15def21d9ac7001ffe9f2a47863efbf4
BLAKE2b-256 b3180a637f51634661b638e25ad55a13ba9084748a18df2ade7bcb5de9cef7ec

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fb63baa22ee9a88725641968239c71d060e5500b784c9151071e3cc693a4b6f1
MD5 2127f7d2faee168ae84775629c49e725
BLAKE2b-256 ec9524005bef874f08389fdca24e647c92ed8f902ecf1bc0b081c1815faeda00

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9428e7930bc63fb7aa4fb123a6a50e7f242c96fca072580ff0bc38e97e274838
MD5 aafd1183be128e2763103a6439ac9b7b
BLAKE2b-256 8b283b12c45d5b8e672cadcc46101ec0db6ffb61a0a122439d85ce705fa505fd

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 c95dce303cb1e9621e595e8bcb5c42854aeaa6b70da1c968d088296139db03e6
MD5 c468b89a92dc18977fab749e86f03038
BLAKE2b-256 e104e49218d33698b8f851167ca014a2f4c016caef1ab8cb605c996981316055

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c541a8d118ab1bed89914cb00ef00d1774f1deef888cc55392c9d8e3df659f94
MD5 bc1376d448ff6a49e5cd90c051e78553
BLAKE2b-256 42b9bd6783bfb2681eeb1578829d3298bf049745f00cb5756deef0d4ba0400cb

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 ec62de7f3033d2f19a4db8389cfaeeea98473ab9ab7b391d372f6c0e4cba3954
MD5 c74f5e533557a2e3d12070fef0ff4693
BLAKE2b-256 58725fe217cb03f452f21c55255b16a1e326e1b786176d8b2a1f3bb9a448b056

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2165b1d9390fdfaaef39d4c035abd7f72f262d4fa8e37385c86bd06b3752c9fd
MD5 6505a215ee0e556ce2debcc4995805ab
BLAKE2b-256 27c293ba84c87921957dafb0874b46c5b60949696e26634e2f5e7fb2e59ce445

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 93256db8fb3ed9402ac62d63088b72e3026deb685593d4b6ff71daf85ba553a9
MD5 41eba0ee48c7fc8e33e4b3a754ffa9e0
BLAKE2b-256 1c9773f1d59c6b9f11fb19526ebe33a588f46d10280e7ce34ce38f4b8c5e980a

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a8ed4c8924f3c2b82f5fd5f597529bc023f345c630a25701d4bf59c5d65f1c03
MD5 c23bed27602575a9e919d7f96f194b3b
BLAKE2b-256 97f3a15062b4c7a41d5e6bf58319884ef9025487503418176040760974dc22d3

See more details on using hashes here.

File details

Details for the file moderngl-5.1.0-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for moderngl-5.1.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 12bf9e0d4a75e5fac0a5736bd1b13b56a009bce2591f7bc677cd836b155bfe86
MD5 f1e743763f9d5f24ed642293df5fdc90
BLAKE2b-256 f2942e395867adb10e80b53cce33f55d735f350b38864eb92c63a62194ee9673

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page