Portable OpenGL Context
Project description
glcontext
glcontext is a library providing OpenGL implementation for ModernGL on multiple platforms.
Backends
A glcontext backend is either an extension or a submodule of the glcontext package.
The package itself does not import any of the backends.
Importing the base package glcontext
must safe and lightweight.
Structure
Every backend of glcontext must provide a factory function:
def create_context(*args, **kwargs) -> GLContext:
pass
The create_context method can take any number of positional and keyword arguments. The factory function must return an object supporting the following methods:
def load(self, name:str) -> int:
pass
The load method takes an OpenGL function name as an input and returns a C/C++ function pointer as a python integer. The return value must be 0 for not implemented functions.
def __enter__(self, name:str):
pass
The enter method calls ___MakeCurrent
to make the GLContext the calling thread's current rendering context.
___MakeCurrent
stands for wglMakeCurrent
, glxMakeCurrent
, ...
def __exit__(self, exc_type, exc_val, exc_tb):
pass
The exit method calls ___MakeCurrent
to make the GLContext no longer current.
def release(self):
pass
The release method destroys the OpenGL context.
Development Guide
There are "empty" example backends provided for developers to help adding new backends to the library. There is a pure python example in empty.py and an extension example in empty.cpp. Besides their name match, they do not depend on each other, they are independent submodules of glcontext.
An "portable" backend implementation must load its dependency at runtime. This rule is for simplifying the build of the entire package. If an implementation cannot provide a "portable" backend, it will not be added to this library. Non "portable" backends are welcome as third party libraries.
A backend must be lightweight, its size must fit within reasonable limits.
To add support for new platforms one must edit the setup.py
too.
Platform specific dependencies are exceptions from the "portability" rule.
Example for platform specific dependencies:
gdi32.lib
on windowslibdl.a
on linux
Please note that libGL.so
is loaded dinamically by the backends.
Running tests
pip install -r tests/requirements.txt
pytest tests
Contributing
Contribution is welcome.
Pull Requests will be merged if they match the Development Guide.
For prototypes, pure python implementations using ctypes are also welcome. We will probably port it to a proper extension in the future.
Please ask questions here.
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
Built Distributions
Hashes for glcontext-1.0.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a31f66567123af58edecf089f8f691db7f3703e4e5a0e919633db5e98fefe10 |
|
MD5 | 0fcf3df10edcbca643ef3f0047ebbd12 |
|
BLAKE2b-256 | 1991990290b6416a3dd8d0cb42570ff2b04dd47b4ba50b2341dd0538b83b54c5 |
Hashes for glcontext-1.0.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fb95875ce60caaa9d84b66c6b3742baa6dc9f0349086ea778fca47b199f59b8 |
|
MD5 | 059d256128450ffe024dc8a9bd531ff1 |
|
BLAKE2b-256 | 4621117cd01c11237b937147f9c8aaf037bfaef4bf6cb57f9c01f743b09883df |
Hashes for glcontext-1.0.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c522f0309f943d9e220d41415584bdb26a7ca56e1c02807103b6290c0b40e94 |
|
MD5 | f2341370acf81570aa7d7b7c2fbf8ec7 |
|
BLAKE2b-256 | 6299e492dd8ce663e8956d9a42785539e8ebf10b5de46d8d1ca08deb49214203 |
Hashes for glcontext-1.0.1-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa864691ac6594e3b65e3d6708d95d3cb9620d27917e104b3eda021dccdb5cef |
|
MD5 | 59d05e19dc77488362642229a536929b |
|
BLAKE2b-256 | abd794159312b637d1049e7b25a3ee4b4091d77608a48265944bc1a97c2261a1 |
Hashes for glcontext-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e117ea26641c67c0e92a37eed75f11953b7d11920842970b7d89c1adb494e71 |
|
MD5 | d8fb32c4da6e7a9f796a5059788d78b2 |
|
BLAKE2b-256 | 265985b013f14abdf153197205aa38f08f860df7ce5a7f952c8371ae1ed39653 |
Hashes for glcontext-1.0.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7759ca3cc2c61030f4d321efcab288e8ddd3b3ed7c339b15ea9c3985a06d0228 |
|
MD5 | 68f9bec16cb38fbaac2738b996af0a34 |
|
BLAKE2b-256 | 04d54ae552e0c664404b93222aa1e95ba67b56895a8b3bd940338bb4846c648c |
Hashes for glcontext-1.0.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84a7f8273f3e99a5327dee9e339797e96772b60e2a482a63eeddd39c3ee839bb |
|
MD5 | 7e45842731a349127c43785ffd09c3a4 |
|
BLAKE2b-256 | c4bedea015e2853993a11415a582b0dcc02adf57323f9ce48ab4551985a7fd63 |
Hashes for glcontext-1.0.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65afef4cf94fe3630c94769cad70d416118fc8efcbb21af168cadb805e45cbfb |
|
MD5 | 69467577618212ae7eba346b051ea9e6 |
|
BLAKE2b-256 | b583481d48a52f8a90f5fce0cb2517f49cc24af4a8089b77267534d46216198e |
Hashes for glcontext-1.0.1-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d35c203f011dd7381662d0079fa9cc175a38bcaa6eabe278465c51968cf71c8a |
|
MD5 | a1c350407b4d5275bda46282ca840373 |
|
BLAKE2b-256 | d207d1ac7f41a6adca05ab1441e9ff02a882bb3661240ebcbebccbea99e0f09c |
Hashes for glcontext-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75fd4a9debfdd8121a352d90f9e8ded42a1e040f1ea8ba3143c3b0cd514dafcc |
|
MD5 | 03ad4273459dbad8bfb09c9e227f712c |
|
BLAKE2b-256 | 45eb9044b9a4c15de7414bdc0d41ed89d23ba1e6bbcfc5a3b5d03ae3f96b9a63 |
Hashes for glcontext-1.0.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26ebaef488d3438ed6c00d06e02c2f07d3a711c8b0d07d8f7f82562b4fe4219e |
|
MD5 | 956b211a90878f323901492a7e5bf3c7 |
|
BLAKE2b-256 | 9128b0d3e487b320310737e2e52ff3f75f9613f5c2f2a9c36b3b7cd5f040a776 |
Hashes for glcontext-1.0.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18958aab5b780bc6281b8488eaaff00f55cf3402c28cc117f5e6cd4d6dbdac42 |
|
MD5 | f3459bda3a7d4bb78991bcac66ec46a0 |
|
BLAKE2b-256 | d77d610b099550126dd02a69e2d15924350d47f010fc36c6417c9687e6c66c95 |
Hashes for glcontext-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af3794ed420c81783d10fefb44da363958ffd924534fda4ee0b9bef64f3abd9 |
|
MD5 | 7e829fef8c71a21eeba5fa588f8f0edc |
|
BLAKE2b-256 | 4e8a60232a3d1c2b61ea03fb750662191024ac8b4cfa4216cb0be964b49d77bc |
Hashes for glcontext-1.0.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2717e6656ccd83868c358029bb9af18bf75050ed569ca200015eb74be775deb |
|
MD5 | 03ccc88c6c0d25f3c3c5589d5607ed6d |
|
BLAKE2b-256 | bd64e85c07c280ba642988f4b3a4057358e19f5c065f7958ee5d6462c5a430ec |
Hashes for glcontext-1.0.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8755ae7704058421fa84106ae0f08aaa4c62d752cbf2954951a5ee970b92241 |
|
MD5 | 8358d874e57b4dd291662d9f32643c95 |
|
BLAKE2b-256 | 127239b5e4694b34f5fa19784386d8926888efc2e7b583837c9bd10e5e0b31dc |
Hashes for glcontext-1.0.1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ae4965d1a5930b60c7e3ce6303cf4b2b2b6461c34328489401c7a2ee0c6a2a9 |
|
MD5 | bb06ff3ea191bd46756e7e02378bd216 |
|
BLAKE2b-256 | ac4ab43daff3ea6607b5519e90d7b7c8185ce5e9dc262eda8645bae8e91be536 |
Hashes for glcontext-1.0.1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b88d7f6f0d5eb8e24fefb186be824fd7093a9a954d043aa287d3af3afc56e9a3 |
|
MD5 | 607c4354aa6599af68b3b34f0f519df1 |
|
BLAKE2b-256 | 86bb2acd17964ae2a0ba689613474f3ff0dce52103be30904947906317cfb7a0 |
Hashes for glcontext-1.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad49dcb22cd99baae0f2fe524b8ff9ff155cd791f33324720bcaea367ba5bc4a |
|
MD5 | eda27022d03ec3dd90dbc25582f41c14 |
|
BLAKE2b-256 | 0bd649d6d76c424d28011f80b3a85c4397ea5a56574cb1844e6f276062e2edb6 |
Hashes for glcontext-1.0.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efdd4e4aab55a64b85121e74caf4f5e54e779a8ccb67c7fde7640341348f7011 |
|
MD5 | 8b8793bef91d793020f6203848827e31 |
|
BLAKE2b-256 | 646d114d0256d673fb23cd0b33e54f180159a9dca7d9e21b36a79cdb17d56e61 |
Hashes for glcontext-1.0.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86d18e4781595f2a2ab4e8e7bce3ec2a08fe57168fb88deee7bbe75a0e6e02b7 |
|
MD5 | c1445417eddbae0bbd3ecbb00591268b |
|
BLAKE2b-256 | 36b5d74c10edf21dba1bb731a88a8c4d472ae573db64c8ddafa7344bc42aadc4 |