Skip to main content

A ctypes-based wrapper for GLFW3.

Project description

This module provides Python bindings for GLFW (on GitHub: glfw/glfw). It is a ctypes wrapper which keeps very close to the original GLFW API, except for:

  • function names use the pythonic words_with_underscores notation instead of camelCase

  • GLFW_ and glfw prefixes have been removed, as their function is replaced by the module namespace (you can use from glfw.GLFW import * if you prefer the naming convention used by the GLFW C API)

  • structs have been replaced with Python sequences and namedtuples

  • functions like glfwGetMonitors return a list instead of a pointer and an object count

  • Gamma ramps use floats between 0.0 and 1.0 instead of unsigned shorts (use glfw.NORMALIZE_GAMMA_RAMPS=False to disable this)

  • GLFW errors are reported as glfw.GLFWError warnings if no error callback is set (use glfw.ERROR_REPORTING=False to disable this, set it to ‘warn’ instead to issue warnings, set it to ‘log’ to log it using the ‘glfw’ logger or set it to a dict to define the behavior for specific error codes)

  • instead of a sequence for GLFWimage structs, PIL/pillow Image objects can be used

Installation

pyGLFW can be installed using pip:

pip install glfw

Windows

The GLFW shared library and Visual C++ runtime are included in the Python wheels.

To use a different GLFW library, you can set PYGLFW_LIBRARY to its location.

macOS

The GLFW shared library for 64-bit is included in the Python wheels for macOS.

If you are using a 32-bit Python installation or otherwise cannot use the library downloaded with the wheel, you can build and install it yourself by compiling GLFW from source (use -DBUILD_SHARED_LIBS=ON).

pyGLFW will search for the library in a list of search paths (including those in DYLD_LIBRARY_PATH). If you want to use a specific library, you can set the PYGLFW_LIBRARY environment variable to its path.

Linux

The GLFW shared library is included in the Python wheels for Linux. Although pyGLFW will try to detect whether the GLFW library for Wayland or X11 should be used, you can set the PYGLFW_LIBRARY_VARIANT variable to wayland or x11 to select either variant of the library.

If you cannot use these on your system, you can install the GLFW shared library using a package management system (e.g. apt install libglfw3 on Debian or Ubuntu) or you can build and install it yourself by compiling GLFW from source (use -DBUILD_SHARED_LIBS=ON).

pyGLFW will search for the library in a list of search paths (including those in LD_LIBRARY_PATH). If you want to use a specific library, you can set the PYGLFW_LIBRARY environment variable to its path.

cx_Freeze / PyInstaller

pyGLFW is unable to dynamically search for the GLFW library on non-Windows platforms if running in an executable frozen with cx_Freeze or PyInstaller, so a path to the library must be provided using the PYGLFW_LIBRARY environment variable.

Development Version

If you are using the development version of GLFW and would like to use wrappers for currently unreleased macros and functions, you can instead install:

pip install glfw[preview]

or set the PYGLFW_PREVIEW environment variable.

Note, however, that there will be a slight delay between the development version of GLFW and the wrappers provided by this package.

Example Code

The example from the GLFW documentation ported to pyGLFW:

import glfw

def main():
    # Initialize the library
    if not glfw.init():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.create_window(640, 480, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

    # Make the window's context current
    glfw.make_context_current(window)

    # Loop until the user closes the window
    while not glfw.window_should_close(window):
        # Render here, e.g. using pyOpenGL

        # Swap front and back buffers
        glfw.swap_buffers(window)

        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()

if __name__ == "__main__":
    main()

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

glfw-2.6.1.tar.gz (31.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl (493.4 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8Windows x86-64

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl (497.3 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8Windows x86

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl (207.9 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl (199.2 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl (122.0 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8manylinux: glibc 2.12+ x86-64

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl (115.8 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8manylinux: glibc 2.12+ i686

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl (92.4 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8macOS 11.0+ ARM64

glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl (96.6 kB view details)

Uploaded Python 2Python 2.7Python 3Python 3.0Python 3.1Python 3.2Python 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8macOS 10.6+ Intel (x86-64, i386)

File details

Details for the file glfw-2.6.1.tar.gz.

File metadata

  • Download URL: glfw-2.6.1.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1.tar.gz
Algorithm Hash digest
SHA256 e15c21f06e74cc9740bf36c3c618b5f0d015ef09fb4e216d138967d8ee532567
MD5 8b33fcba8a20309884e8fb5bd51dcd1f
BLAKE2b-256 11aca9196051df37d39dfdfe658ca61921a53db933048f15182a1c818fa12518

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
  • Upload date:
  • Size: 493.4 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
Algorithm Hash digest
SHA256 7631f7bc1716dd1c521a2cefb7d3715efa4b369a4c2ce99ad2f6a988a096caee
MD5 e545e1199519c67f74e1a4492b5b7315
BLAKE2b-256 4baebe82465ff3cb6dc513ef55d039d7156f043a94b98f78ce6009a891d3bbed

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
  • Upload date:
  • Size: 497.3 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
Algorithm Hash digest
SHA256 233433028ab06cca2c09dcd3ae47419b5058de4c7bd7f25f227b4c113e41d85a
MD5 24d9f3754100e04b379cce6d3294072b
BLAKE2b-256 ec312e7c6510015f9d5b8a5c75b6057b60c53c97813789e7126f9040ecb2a6ec

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2393284597be8303a0f2d6216e1acd7138ab2e7cc398b86e35c63a0e54c573bd
MD5 785ae2d93a2e846298c8fe65a2141a90
BLAKE2b-256 b35ae923977b69a4ab3f31baf1960eef3ee3622acb7cb5b67fbfdda148e1d8e2

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2cae8179eab1d7cd345e6622c972d3a9fb7b765eed91e06b90a4cad8021f3b69
MD5 751771a07aba3b25a33636290549a430
BLAKE2b-256 fbf8a8e2985702fa7c8b6136ed4f9c2ed9ac100f44c94766cd49e5f8261f2da8

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 122.0 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 bc0141a2d1ad8a84bb84fd6980b7b70c6635ac8b7daf1c55c29a7fe38b1a5989
MD5 e384aa98f1ba8835e8d8d266ba2164b3
BLAKE2b-256 b34741d3f801bf3cf5083e64385e62d38793a8cef9a5d8ccec2b21d50d155016

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 115.8 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 e9f6022541d1acfe6fdad442a757df2e5c0d13a9ace64d984a9910a38ea6ff06
MD5 2f3b80a5f4b1b489f6ad48af569cad56
BLAKE2b-256 b1d0ef779630ce898d2addae779bbb928d0ce39cb88f2be4861387e6bf3e2760

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 92.4 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 352712889169ce3fecc57d1092466e3746bd4e1326fc0bbab81bb09d180356c5
MD5 2397e47ef8fc8971614cba09fd44480d
BLAKE2b-256 389dc21a9d378540dd7bec81bdef2b3d10979ca503c5138b89774a6ab7a26b9a

See more details on using hashes here.

File details

Details for the file glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl.

File metadata

  • Download URL: glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 96.6 kB
  • Tags: Python 2, Python 2.7, Python 3, Python 3.0, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for glfw-2.6.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 9facdbca1965393109dfd5eea88bb4e255ec3ca0847950e2cd6977bb63e76a34
MD5 09ffaa89cbeaf33d244f50d8d238f56f
BLAKE2b-256 5778854bbe1f56511ea83eb515eca170d17469d325fd9236c6ed139771a4c2a4

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