Skip to main content

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 6 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 is 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 --dev

To run the example:

PYTHONPATH=src pipenv run ./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

pyglpainter-2.0.1.tar.gz (76.4 kB view details)

Uploaded Source

File details

Details for the file pyglpainter-2.0.1.tar.gz.

File metadata

  • Download URL: pyglpainter-2.0.1.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for pyglpainter-2.0.1.tar.gz
Algorithm Hash digest
SHA256 ce49d4ee69a08203937991f1e6a69f7e901c7ae1dbfe703d8ec319003cf4a482
MD5 bd9be271f208a97e8a72f3ce3c092c5d
BLAKE2b-256 da08e567a51e20e865524aeef6b7e8d58496643cb018389717af83629d7bd642

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page