Minimalistic, modern OpenGL drawing for technical applications
Project description
pyglpainter
Minimalistic, modern OpenGL drawing library for technical applications, teaching or
experimentation. It is implemented in Python 3 with Qt 5 bindings (it inherits from QOpenGLWidget
).
It provides a simple Python API to draw raw OpenGL primitives (LINES
, LINE_STRIP
, TRIANGLES
, etc.)
as well as a number of useful composite primitives
(see classes Grid
, Star
, CoordSystem
, Text
, Circle
, Arc
, HeightMap
, OrthoLineGrid
).
All objects/items can either be drawn as real 3D world entities (which optionally support "billboard" mode), or as a 2D overlay.
The user can interactively navigate using the mouse via the classical Pan-Zoom-Rotate paradigm implemented via a virtual trackball (using quaternions for rotations).
Background
This code was originally written for a CNC application, but then split off and made more general.
This library was developed to produce simple technical visualizations and minimalistic line drawings in 3D space; it does not implement a hierarchical scene graph. To be extensible, shader code has to be supplied by the application.
It uses the "modern", shader-based, OpenGL API rather than the deprecated "fixed pipeline".
Qt has been chosen not only because it provides the GL environment, but also vector, matrix and quaternion math. A port of this Python code into native Qt C++ would therefore be trivial.
Installation
pip install pyglpainter
Usage
The test directory of the source repository provides a full integration example, which can also be run for testing.
Most of the time, calls to item_create()
are enough to build a 3D world with objects
in it (the name for these objects here is "items"). Items can be rendered using different shader
programs.
Mouse Navigation
Left Button drag left/right/up/down: Rotate camera left/right/up/down
Middle Button drag left/right/up/down: Move camera left/right/up/down
Wheel rotate up/down: Move camera ahead/back
Right Button drag up/down: Move camera ahead/back (same as wheel)
One particular choice was to hold the camera's field of view constant; "Zooming" can be achieved by moving the camera forward along its look axis.
Requirements
- The Python version specified in the file
.python-version
- OpenGL version 2.1 (with GLSL version 1.20)
Development
Dependencies are managed using pipenv
:
pip install pipenv --user
pipenv install
To run the example:
PYTHONPATH=src pipenv run python ./test/example.py
Building
pipenv run make build_deps
pipenv run make dist
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyglpainter-1.0.3.tar.gz
.
File metadata
- Download URL: pyglpainter-1.0.3.tar.gz
- Upload date:
- Size: 66.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b5a3566516cc53611c84be2f958cfbbe02fb0e51bd332288e8d7f05aacecf99a
|
|
MD5 |
8cc6ef04c21a43f54f37d10f3429f6d1
|
|
BLAKE2b-256 |
012a4befd071bffe931217f87b34a7fa03b5f406949ef71fef83f2fad81cd690
|