Aljenci / ModernGL

:boom: modern OpenGL binding for Python

Home Page:https://pythonhosted.org/ModernGL/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModernGL

PyPI PyPI PyPI github
Donate Chat PyPI

Description

OpenGL is a great environment for developing portable, platform independent, interactive 2D and 3D graphics applications. The API implementation in Python is cumbersome, resulting in applications with high latency. To solve this problem we have developed ModernGL, a wrapper over OpenGL that simplifies the creation of simple graphics applications like scientific simulations, small 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 the same performance and quality, with less code written.

Sample

ModernGL.Init()

prog = ModernGL.NewProgram([
	ModernGL.NewVertexShader('''
		#version 330 core
		in vec2 vert;
		void main() {
			gl_Position = vec4(vert, 0.0, 1.0);
		}
	'''),
	ModernGL.NewFragmentShader('''
		#version 330 core
		out vec4 color;
		void main() {
			color = vec4(0.2, 0.6, 0.9, 1.0);
		}
	'''),
])

vbo = ModernGL.NewVertexBuffer(struct.pack('6f', 0, 0, 1, 0, 0, 1))
vao = ModernGL.NewVertexArray(prog, vbo, '2f', ['vert'])

ModernGL.RenderTriangles(vao, 3)

How to install

pip install ModernGL

for Ubuntu:

apt-get install python3-dev
apt-get install libgl1-mesa-dev
pip3 install ModernGL

some examples depend on: PyQt5 and GLWindow

pip3 install PyQt5
pip install GLWindow

PyQt5 is platform independent. GLWindow is windows only.

How to use

Please follow the Examples or Tutorials.

Links

Examples
Documentation
Questions
PyPI
Github Repository
Github Page
Github Docs

Pull requests are welcome!

Documentation

Use the builtin help() for the latest docs.

The Documentation will be updated soon.

Examples

Please follow the Examples.

Supported Versions

Python

Python-3.4 Python-3.5 Python-3.6

OpenGL

OpenGL-3.0 OpenGL-3.1 OpenGL-3.2 OpenGL-3.3
OpenGL-4.0 OpenGL-4.1 OpenGL-4.2 OpenGL-4.3 OpenGL-4.4 OpenGL-4.5

Checkout the OpenGL Registry for core specifications.

minimum OpenGL support per method

Method Version
BuildMipmaps OpenGL-3.1
Clear OpenGL-3.1
DebugInfo OpenGL-3.1
DebugVar OpenGL-3.1
DeleteComputeShader OpenGL-3.1
DeleteFramebuffer OpenGL-3.1
DeleteIndexBuffer OpenGL-3.1
DeleteProgram OpenGL-3.1
DeleteShader OpenGL-3.1
DeleteStorageBuffer OpenGL-3.1
DeleteTexture OpenGL-3.1
DeleteUniformBuffer OpenGL-3.1
DeleteVertexArray OpenGL-3.1
DeleteVertexBuffer OpenGL-3.1
DisableAttributes OpenGL-3.1
DisableBlend OpenGL-3.1
DisableCullFace OpenGL-3.1
DisableDepthTest OpenGL-3.1
DisableMultisample OpenGL-3.1
EnableAttributes OpenGL-3.1
EnableBlend OpenGL-3.1
EnableCullFace OpenGL-3.1
EnableDepthTest OpenGL-3.1
EnableMultisample OpenGL-3.1
EnableOnly OpenGL-3.1
ExampleMethod OpenGL-3.1
GetInfo OpenGL-3.1
Init OpenGL-3.1
LineSize OpenGL-3.1
NewAdvancedVertexArray OpenGL-3.1
NewComputeShader OpenGL-4.3
NewFragmentShader OpenGL-3.1
NewFramebuffer OpenGL-3.1
NewGeometryShader OpenGL-3.2
NewIndexBuffer OpenGL-3.1
NewProgram OpenGL-3.1
NewStorageBuffer OpenGL-4.3
NewTessControlShader OpenGL-4.0
NewTessEvaluationShader OpenGL-4.0
NewTexture OpenGL-3.1
NewTransformProgram OpenGL-3.1
NewUniformBuffer OpenGL-3.1
NewVertexArray OpenGL-4.0
NewVertexBuffer OpenGL-3.1
NewVertexShader OpenGL-3.1
PointSize OpenGL-3.1
ReadDepthPixel OpenGL-3.1
ReadDepthPixels OpenGL-3.1
ReadPixel OpenGL-3.1
ReadPixels OpenGL-3.1
ReadStorageBuffer OpenGL-4.3
RenderLineLoop OpenGL-3.1
RenderLineStrip OpenGL-3.1
RenderLineStripAdjacency OpenGL-3.2
RenderLines OpenGL-3.1
RenderLinesAdjacency OpenGL-3.2
RenderPoints OpenGL-3.1
RenderTriangleFan OpenGL-3.1
RenderTriangleStrip OpenGL-3.1
RenderTriangleStripAdjacency OpenGL-3.2
RenderTriangles OpenGL-3.1
RenderTrianglesAdjacency OpenGL-3.2
RunComputeShader OpenGL-4.3
SetTextureFiltered OpenGL-3.1
SetTextureMipmapped OpenGL-3.1
SetTexturePixelated OpenGL-3.1
SetUniform OpenGL-3.1
TransformLineLoop OpenGL-3.1
TransformLineStrip OpenGL-3.1
TransformLineStripAdjacency OpenGL-3.2
TransformLines OpenGL-3.1
TransformLinesAdjacency OpenGL-3.2
TransformPoints OpenGL-3.1
TransformTriangleFan OpenGL-3.1
TransformTriangleStrip OpenGL-3.1
TransformTriangleStripAdjacency OpenGL-3.2
TransformTriangles OpenGL-3.1
TransformTrianglesAdjacency OpenGL-3.2
UpdateIndexBuffer OpenGL-3.1
UpdateStorageBuffer OpenGL-4.3
UpdateTexture OpenGL-3.1
UpdateUniformBuffer OpenGL-3.1
UpdateVertexBuffer OpenGL-3.1
UseFramebuffer OpenGL-3.1
UseStorageBuffer OpenGL-4.3
UseTexture OpenGL-3.1
UseTextureAsImage OpenGL-4.2
UseUniformBuffer OpenGL-3.1
Viewport OpenGL-3.1

Cross-platform

  • tested on Ubuntu 16.04
  • tested on Windows 7
  • tested on Windows 10

Ubuntu Win7 Win10

About

:boom: modern OpenGL binding for Python

https://pythonhosted.org/ModernGL/

License:MIT License


Languages

Language:C++ 95.1%Language:Python 4.5%Language:CSS 0.2%Language:HTML 0.2%