All Projects → moderngl → Moderngl

moderngl / Moderngl

Licence: mit
Modern OpenGL binding for python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Moderngl

Oitdemo
Order Independent Transparency Demo
Stars: ✭ 10 (-98.96%)
Mutual labels:  opengl
Opengl Seed
⚪🌱A modern OpenGL starter repo that you could use to get the ball rolling.
Stars: ✭ 20 (-97.91%)
Mutual labels:  opengl
Alacritty
Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.
Stars: ✭ 36,273 (+3686.33%)
Mutual labels:  opengl
Disposable Email Domains
a list of disposable and temporary email address domains
Stars: ✭ 873 (-8.87%)
Mutual labels:  pypi
Github Trending Cli
A Python package which lists trending repositories and developers from Github
Stars: ✭ 15 (-98.43%)
Mutual labels:  pypi
Metalpetal
A GPU accelerated image and video processing framework built on Metal.
Stars: ✭ 907 (-5.32%)
Mutual labels:  opengl
Permafrost Engine
An OpenGL RTS game engine written in C
Stars: ✭ 851 (-11.17%)
Mutual labels:  opengl
Satellitesimulator
🚀 A simple Qt/OpenGL satellite orbit simulator
Stars: ✭ 28 (-97.08%)
Mutual labels:  opengl
Glumpy
Python+Numpy+OpenGL: fast, scalable and beautiful scientific visualization
Stars: ✭ 882 (-7.93%)
Mutual labels:  opengl
Gli
jvm gli
Stars: ✭ 21 (-97.81%)
Mutual labels:  opengl
Tess Opt
Demonstration of how we can use tessellation shaders to make faster fragment shaders.
Stars: ✭ 13 (-98.64%)
Mutual labels:  opengl
Youtube Dl Gui
A cross platform front-end GUI of the popular youtube-dl written in wxPython.
Stars: ✭ 7,914 (+726.1%)
Mutual labels:  pypi
Socli
Stack overflow command line client. Search and browse stack overflow without leaving the terminal 💻
Stars: ✭ 911 (-4.91%)
Mutual labels:  pypi
Q3dobserver
Multi-platform C++11 library based on Qt for creating 3D viewer widgets
Stars: ✭ 13 (-98.64%)
Mutual labels:  opengl
Imac Tower Defense
OpenGl 4.4 game made with Entity Component System
Stars: ✭ 28 (-97.08%)
Mutual labels:  opengl
Kepler3d
OpenGL and C++14 game engine that loads glTF 2.0
Stars: ✭ 9 (-99.06%)
Mutual labels:  opengl
Sidecar
Some old C++ code I developed while at MIT. Could be useful if you have an old radar lying around.
Stars: ✭ 20 (-97.91%)
Mutual labels:  opengl
Scalanative Graphics Bindings
OpenGL and SDL2 bindings for Scala Native
Stars: ✭ 30 (-96.87%)
Mutual labels:  opengl
Dotfeather
A closs-platform generic gameengine built on C#/.NET Standard 2.1
Stars: ✭ 28 (-97.08%)
Mutual labels:  opengl
Jetson stats
📊 Simple package for monitoring and control your NVIDIA Jetson [Xavier NX, Nano, AGX Xavier, TX1, TX2]
Stars: ✭ 908 (-5.22%)
Mutual labels:  pypi

preview

ModernGL

pypi anaconda rtd

ModernGL is a python wrapper over OpenGL 3.3+ core that simplifies the creation of simple graphics applications like scientific simulations, games or user interfaces. Usually, acquiring in-depth knowledge of OpenGL requires a steep learning curve. In contrast, ModernGL is easy to learn and use, moreover it is capable of rendering with high performance and quality, with less code written. The majority of the moderngl code base is also written in C++ for high performance.

pip install moderngl

NOTE: From moderngl 5.6 context creation is delegated to the glcontext package. This makes us able to expand and improve context creation without releasing new versions of moderngl. It also makes it possible for users to customize their own context creation and the bar for contributing should be lower. New backends can be created using ctypes or C++.

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 PyOpenGL, using the original OpenGL API, you have to write three lines to achieve a simple task like binding a VBO:

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)

With ModernGL you need just one simple line per VBO to achieve the same results:

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 many 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. (Compute Shaders will likely not work depending on how old your PC is.)

You can still try using Mesa but performance would be limited.

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, but we provide a utility library moderngl-window making window creation and resource loading very simple.

Limitations using ModernGL over PyOpenGL?

All the necessary calls are (or can be) implemented in ModernGL. However you can interact with the ModernGL objects from PyOpenGL. If something is missing write an issue or raise a PR.

Supported platforms

  • [x] Windows
  • [x] Linux
  • [x] 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

pip install -r tests/requirements.txt
pytest tests

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

Citation

If you need to cite this repository in academic research:

@Online{Dombi2020,
  author = {Szabolcs Dombi},
  title = {ModernGL, high performance python bindings for OpenGL 3.3+},
  date = {2020-05-01},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/moderngl/moderngl}},
  commit = {<insert hash if needed>}
}

If commit hash is required this can be found per release here: https://github.com/moderngl/moderngl/releases

Contributors

and many others

Thank You!

Contributions are welcome. (Please add yourself to the list)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].