OpenGL Mathematics library for Python
Project description
GLSL + Optional features + Python = PyGLM
A mathematics library for graphics programming.
Work in progress.
PyGLM is using GLM by G-Truc to offer a lot of the original features.
Currently, some features haven't yet found their way into PyGLM and some never will (such as unstable extensions).
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 mostly 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 3.5 or higher. (Prior versions of Python - such as Python 2 - were supported up to PyGLM version 0.4.8b1)
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.
Differences to glm
Instead of using double colons (::) for namespaces, periods (.) are used, so
glm::detail::vec2
becomes glm.detail.vec2
.You can also use the base namespace glm (e.g.
glm.vec2
).PyGLM doesn't support precision qualifiers. All types use the default precision (
packed_highp
).If a glm function normally accepts
float
and double
arguments, the higher precision (double
) is used.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
.All types are initialized by default to avoid memory access violations.
(i.e. the macro
GLM_FORCE_CTOR_INIT
is defined)In case you need the size of a PyGLM datatype, you can use
glm.sizeof(<type>)
The function
glm.frexp(x, exp)
returns a tuple (m, e)
, if the input arguments are numerical.This function may issue a
UserWarning
. You can silence this warning using glm.silence(1)
.The function
glm.value_ptr(x)
returns a ctypes pointer of the respective type.I.e. if the datatype of
x
is float
, then a c_float
pointer will be returned.Likewise the reverse-functions (such as
make_vec2(ptr)
) will take a ctypes pointer as their argumentand return (in this case) a 2 component vector of the pointers underlying type.
glm.silence(ID)
can be used to silence specific warnings.Supplying an id of 0 will silence all warnings.
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.xxy) vec3( 7, 7, 0 ) >>> m = glm.mat4() >>> print(m) [ 1 | 0 | 0 | 0 ] [ 0 | 1 | 0 | 0 ] [ 0 | 0 | 1 | 0 ] [ 0 | 0 | 0 | 1 ] >>> v = glm.vec4(1, 2, 3, 4) >>> print(v + (8, 7, 6, 5)) vec4( 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.6.1b1.tar.gz
(265.3 kB
view hashes)
Built Distributions
PyGLM-0.6.1b1-cp37-cp37m-win32.whl
(592.6 kB
view hashes)
PyGLM-0.6.1b1-cp36-cp36m-win32.whl
(592.6 kB
view hashes)
PyGLM-0.6.1b1-cp35-cp35m-win32.whl
(814.6 kB
view hashes)
Close
Hashes for PyGLM-0.6.1b1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5535f757ab6aae722bc2b73976effa16a28230cf84a4a817a0d81ee940e08e2e |
|
MD5 | c449460ee2b203605f9eee27bfabd8b6 |
|
BLAKE2b-256 | 9bcc91a4f58ba5755b99f0ea21269082c552f945ca414ff8512355a352561828 |
Close
Hashes for PyGLM-0.6.1b1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42262e4dd3d5d0c8cae78df5636370ce6b2c7214f22947de6a36c54d52d05b3a |
|
MD5 | 17b0ff3376685e4609e583c83a8d7920 |
|
BLAKE2b-256 | 3c69a799c74e9622f2fcfd0697d435eee65f36bf4ef04cfd38a344b6ee5363cf |
Close
Hashes for PyGLM-0.6.1b1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1377eb792396632dd0548eedbf331cbc51321cd11f273c3236b8801204b9e419 |
|
MD5 | 1d91efc63753fe64ce9605f377da3c2f |
|
BLAKE2b-256 | e45755e4d1b704eb2163eb30ab882247960e0a3bd7f890b3f54895da635e5d85 |
Close
Hashes for PyGLM-0.6.1b1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699e64223d3d36a7d6db3a5dbf1af842bffe4468f47279e98d12a49e70e186ae |
|
MD5 | b16e33eed1a49601d29b8e6d3f69f126 |
|
BLAKE2b-256 | b6402592e331f0ba91cdf5e162556916372361df115d1a36dec032b61cfbf67c |
Close
Hashes for PyGLM-0.6.1b1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a553f006b0dc15408caa19c338430336566fe12f5a1809cb20ab5e944ed164 |
|
MD5 | efecc1ec11bbde7a482fe76b0ee687e2 |
|
BLAKE2b-256 | 71cf8720cf220b883ce9dabac689bbb574a40827184735096580ae4a49cb21ad |
Close
Hashes for PyGLM-0.6.1b1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 761fca5cf279070ccaa1cd835e2af7c176fc1e2a84085e6c26082bb788d88c2b |
|
MD5 | a202af8f758712e7da582b0336ab81dc |
|
BLAKE2b-256 | 36d9de0387ce9610dd237dc71c87a1aee972b88c1386f39ef8faf25756eaebb5 |