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
========
.. 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.0.7.tar.gz
(99.4 kB
view hashes)
Built Distributions
Close
Hashes for moderngl-5.0.7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f41161c4cf92221a01c18772d708571190bc4f30f33bd6a250b0315d8667c7a |
|
MD5 | c22ff5c7521ca5ada801253063fda060 |
|
BLAKE2b-256 | 88a582a18ebe404b8024eebf75c55f045c0611e99f4d7bae216c00783a9a56e1 |
Close
Hashes for moderngl-5.0.7-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03103e23049769d7f4ba2dc69254783c4e11b2797715830d2fca99d6f4c067a2 |
|
MD5 | fa165653d50edf9d268f7983dcf71ef0 |
|
BLAKE2b-256 | 2ae47f813207284bc8d4a7f92ca70147e9aa0259c37f9568d931522bcac5dbc0 |
Close
Hashes for moderngl-5.0.7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dd3f66e4f1e3e517b4626df5baf926cd75cdd9a3f92518e6fbc307ea639410a |
|
MD5 | f996f551297f7a3919d03048eaaae458 |
|
BLAKE2b-256 | 15003629bbce71e5fa6ee2c98daf64083c5dcd8748105309fb69f97e402cbc4c |
Close
Hashes for moderngl-5.0.7-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 004ad3076112d407c4b3389198c39f638fed75c47980bea6a5f74bd197243085 |
|
MD5 | 5d5aada221b6ec07b082c790c17ec9c0 |
|
BLAKE2b-256 | 7ad475176e22719188d7dd69e3b6e3e7a5b77b5154bca71cc360a9025e0f3ca5 |
Close
Hashes for moderngl-5.0.7-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be138d6fb6503649c6c0381b01523099e1a6066b52f9bfec84532d3f57567ff4 |
|
MD5 | d99c335019f15a6cc5f8b468865761da |
|
BLAKE2b-256 | 4c92901f03d3800b1285e789a02c285ff147b1d41dddf31ddb874ce53f5a7f68 |
Close
Hashes for moderngl-5.0.7-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b01404409b9854c4c7068adb60c51a1ef28f9096f8713912e821d2200b53cb3f |
|
MD5 | c3a0d9823a5552327fbb356a4f508480 |
|
BLAKE2b-256 | b3ab931864fdabcca4ab2edd08c755da875c4be257fa2029a55ad1a54e73c1c2 |
Close
Hashes for moderngl-5.0.7-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13bae39fca2b67734ff3789c0fcfc1b5838427aee8e158ea9d784c16fe8bedae |
|
MD5 | 21c3521ad9c5a99ff8df0b50d7e0acd3 |
|
BLAKE2b-256 | c463a272389011eb2ce10902bf381cae2e184c73e90e9ec5722bd1279e615bf6 |
Close
Hashes for moderngl-5.0.7-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a69165a091c5f53aa2d73af01562acba40ef715808195c159032cf9602c26ee |
|
MD5 | cf688bffd986d347297f74f636331c98 |
|
BLAKE2b-256 | 99046bdcf68ab93c9e6e8865fc828ae8ba3bf0a6737c5299a507063cdd314810 |
Close
Hashes for moderngl-5.0.7-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de7e0906abbe31d7cd3da953105ecb45307e333431350b63f79dcb2d15564334 |
|
MD5 | 302a879f0087d7e8d45267e873f72fa6 |
|
BLAKE2b-256 | 66872a577b2003764e90e0dbadc015103f68b2d99f38e6ccafed8b068d1be828 |
Close
Hashes for moderngl-5.0.7-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3b23f70963e70785661465add0a84425b654e2bafe509f36fed6c7dbbaf77f7 |
|
MD5 | 0e187d63518517bb06a27eb48e3b6902 |
|
BLAKE2b-256 | 9ff7279871f373772d652e6147e6608b676d9eae94b53789e35693bc4c7e0770 |
Close
Hashes for moderngl-5.0.7-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f0a487f2c5bc73d6275c5a2a6f479590b20e23fbbb794f60916124a370373ae |
|
MD5 | 518d41be49195a702e44010ac0073f88 |
|
BLAKE2b-256 | 44a389dce355183070851d6e8b6842cfcfb4e0550d63f70426743b5e4bb86b53 |