Skip to main content

OpenGL Mathematics library for Python

Project description

GLSL + Optional features + Python = PyGLM
A mathematics library for graphics programming written in C.

Work in progress.

PyGLM is based on GLM by G-Truc offering a lot of the original features.
PyGLM is missing some features, either because they couldn't be implemented properly
or were deemed to be of too low priority (like glm::detail::tvec1).
If you encounter any issues or want to request a feature, please create an issue on the issue tracker.

Tiny Documentation

Why PyGLM?

Besides the obvious - being compatible with GLM - PyGLM offers a variety of features for vector and matrix manipulation.
It has a lot of possible use cases, including 3D-Graphics (OpenGL, DirectX, ...), Physics and more.

At the same time, it has great performance, being between 2x and 10x as fast as numpy!
(depending on the individual function)

Installation

PyGLM supports Windows, Linux, MacOS and other operating systems with either x86 (32-bit) or x64 (64-bit) architecture,
running Python 2 or 3

It can be installed from the PyPI using pip:
pip install pyglm
And finally imported and used:
import glm

Using PyGLM

PyGLM's syntax is very similar to the original GLM's syntax.
There is no need to import anything but glm, as it already contains the entire package.
Instead of using double colons (::) for namespaces, periods (.) are used, so
glm::detail::tvec2
becomes
glm.detail.tvec2
You can also use the base namespace glm.
glm.tvec2

There is no way to set preprocessor definitions (macros).
If - for example - you need to use the left handed coordinate system, you have to use *LH, so
glm.perspective
becomes
glm.perspectiveLH

There is currently no documentation for PyGLM.
Please refer to the source (in Python: *.__doc__) and GLM manuals, references and tutorials.

Example

>>> import glm
>>> v = glm.vec3()
>>> v.x = 7
>>> print(v.xxx)
tvec3(            7,            7,            7 )

>>> m = glm.mat4()
>>> print(m)
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            0 ]

>>> v = glm.vec4(1, 2, 3, 4)
>>> print(v + (8, 7, 6, 5))
tvec4(            9,            9,            9,            9 )

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

PyGLM-0.4.8b1.tar.gz (108.8 kB view hashes)

Uploaded Source

Built Distributions

PyGLM-0.4.8b1-cp37-cp37m-win_amd64.whl (199.5 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

PyGLM-0.4.8b1-cp37-cp37m-win32.whl (175.6 kB view hashes)

Uploaded CPython 3.7m Windows x86

PyGLM-0.4.8b1-cp36-cp36m-win_amd64.whl (199.8 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

PyGLM-0.4.8b1-cp36-cp36m-win32.whl (177.6 kB view hashes)

Uploaded CPython 3.6m Windows x86

PyGLM-0.4.8b1-cp35-cp35m-win_amd64.whl (202.2 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

PyGLM-0.4.8b1-cp35-cp35m-win32.whl (177.6 kB view hashes)

Uploaded CPython 3.5m Windows x86

PyGLM-0.4.8b1-cp34-cp34m-win_amd64.whl (189.5 kB view hashes)

Uploaded CPython 3.4m Windows x86-64

PyGLM-0.4.8b1-cp34-cp34m-win32.whl (179.7 kB view hashes)

Uploaded CPython 3.4m Windows x86

PyGLM-0.4.8b1-cp33-none-win_amd64.whl (189.4 kB view hashes)

Uploaded CPython 3.3 Windows x86-64

PyGLM-0.4.8b1-cp33-none-win32.whl (178.3 kB view hashes)

Uploaded CPython 3.3 Windows x86

PyGLM-0.4.8b1-cp27-cp27m-win32.whl (149.6 kB view hashes)

Uploaded CPython 2.7m Windows x86

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page