Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A awesome-python
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 13
    • Issues 13
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 317
    • Merge requests 317
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Vinta Chen
  • awesome-python
  • Merge requests
  • !893

Add ModernGL

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/szabolcsdombi/moderngl into master Jun 04, 2017
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: szabolcsdombi

What is this Python project?

ModernGL is a python3 module that encapsulates OpenGL in a pythonic way

  • ModernGL on PyPI
  • Documentation
  • Examples
  • Changelog

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 👍 to it, and usually, the maintainer will merge it when votes reach 20.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/szabolcsdombi/moderngl