PyGLM: OpenGL Mathematics library for Python

2.8.3 · active · verified Thu Apr 16

PyGLM is an OpenGL Mathematics library for Python, providing vector and matrix types, and mathematical functions for graphics programming. It is a Python extension written in C++ that wraps the popular GLM (OpenGL Mathematics) library. The current version is 2.8.3. It maintains an infrequent but active release cadence, focusing on stability and compatibility with its underlying C++ counterpart.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic vector and matrix initialization and operations using the `glm` module. It shows how to create vectors and matrices, access components, and perform arithmetic operations.

import glm

# Vector operations
v = glm.vec3()
v.x = 7
print(f"v.xxy: {v.xxy}")

# Matrix initialization
m = glm.mat4()
print(f"m:\n{m}")

# Vector arithmetic with iterables
v_sum = glm.vec4(1, 2, 3, 4) + (8, 7, 6, 5)
print(f"v_sum: {v_sum}")

view raw JSON →