Skip to main content

pyprojector is an asyncronous window for rendering

Project description

pyprojector

pyprojector is a Python 3 module that creates an interpreter independent window. Tight loops, long calculation often prevents us from updating a window, using Python threads adds more complexity and a choppy rendering experience.

How pyprojector works?

A window is created on a new OS thread, the WinAPI takes care of the window. The window has two OpenGL contexts with shared objects. The user can use the the OpenGL context assigned to the current thread to render arbitrary images using OpenGL. The window.update(framebuffer=...) method takes a framebuffer and copies its content into a backbuffer. The backbuffer will be used anytime the window needs a redraw.

Features

  • The user can create and update a window with a minimal API.
  • The rendered frames are quickly copied to a backbuffer maintained by another thread.
  • The user can render depending on the window's visibility.
  • A hidden window have an almost zero performance penalty.
  • The user is not responsible updating a window to avoid dirty frames.
  • The window can be shown/hidden from the system tray.
  • Closing the window just hides the window.
  • A screenshot can be saved with ctrl+s.
  • A ctrl+c in the window raises a KeyboardInterrupt.
  • A screenshot can be taken programatically using window.screenshot().
  • The program can be halted with ctrl+shift+q.
  • The window is refreshed only when necessary.
  • There is a builtin FPS limiter.

Example

import pyprojector

wnd = pyprojector.window((840, 480), __file__, fps=60)
fbo = ... # OpenGL Framebuffer Object

while True:
    # the user's loop
    # do long calculation, train AI, run gyms, ...

    if wnd.visible:
        # render into fbo
        # pass fbo to the window
        wnd.update(fbo)

for more examples please visit the examples.

Acknowledgement

This project is using miniz to save PNG files.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyprojector, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyprojector-1.0.1-cp36-cp36m-win32.whl (28.9 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyprojector-1.0.1-cp36-cp36m-win_amd64.whl (30.6 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyprojector-1.0.1-cp37-cp37m-win32.whl (28.9 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyprojector-1.0.1-cp37-cp37m-win_amd64.whl (30.6 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyprojector-1.0.1.tar.gz (104.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page