OpenGL matrix math utilities for Python?

Question:

Are there any Python libraries available for OpenGL-specific/compatible matrix math on 4×4 matrices?

I need about the feature set offered by Android’s android.opengl.Matrix class.

Asked By: dietr

||

Answers:

You can use numpy to generate data that is compatible with OpenGL. Many of the PyOpenGL calls can take numpy data structures directly (assuming it’s the correct type). Additionally, numpy arrays are typically well arranged in memory, and so you can do what you want with the data (and it’s easy to check how they are arranged).

Answered By: Henry Gomersall

If you already know what you want in OpenGL, why not use PyOpenGL? I believe all the functionality you want should be there, and here are some docs on doing matrix transformations and interfacing with NumPy.

Answered By: ely

I created the library Pyrr to provide all the maths features you need for Core OpenGL.
It features matrices, vectors and quaternions and basic support for other primitives (rectangles, rays, lines, etc).

It has both a procedural API and, more recently, an Object Oriented API which is very powerful.

It’s available on PyPi pip install pyrr and from the github link above.

Feedback, issues and new features are welcome!

Answered By: Rebs

PyGLM might be something to look at as well. The author claims to be 2x to 10x as fast as numpy.
It is based on the popular OpenGL Mathematics, C++ header only, library.

Answered By: gmagno
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.