Created by: szabolcsdombi
What is this Python project?
ModernGL is a python3 module that encapsulates OpenGL in a pythonic way
Features:
- Full linting support - (using vscode and pylint)
- Create GLSL shaders with only a few lines of code
- Create framebuffers and validate them with a single call
- Access cool OpenGL features by writing clean and self-explaining code
- vscode snippets for fast prototyping
- Render to pillow image - (no window required)
What's the difference between this Python project and similar ones?
ModernGL - PyOpenGL
Pros
- Same quality and performance with less code written
- Readable code and no
ctypes
required - Rendering without a window
- Fully linted
Cons
- One can mix ModernGL and PyOpenGL so there are no drawbacks.
Example
Using PyOpenGL
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
vbo1 = ctx.buffer(b'Hello World!')
vbo2 = ctx.buffer(reserve=1024, dynamic=True)
Some cool features
# Read the content
>>> vbo1.read()
b'Hello World!'
# Copy between buffers
>>> ctx.copy_buffer(vbo2, vbo1)
>>> vbo2.read(5)
b'Hello'
# Buffer re-specification
>>> vbo2.orphan()
>>> vbo2.write(b'Some other data')
--
Anyone who agrees with this pull request could vote for it by adding a