OpenGL matrix math utilities for Python?

2020-07-06 07:23发布

Before I do it myself, are there any Python libraries available for OpenGL-specific/compatible matrix math on 4x4 matrices? Basically, I need about the feature set offered by Android's android.opengl.Matrix class.

4条回答
Rolldiameter
2楼-- · 2020-07-06 08:01

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.

查看更多
走好不送
3楼-- · 2020-07-06 08:03

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!

查看更多
何必那么认真
4楼-- · 2020-07-06 08:05

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).

查看更多
趁早两清
5楼-- · 2020-07-06 08:15

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.

查看更多
登录 后发表回答