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.

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.

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.5.1.tar.gz (30.4 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl (491.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.8Windows x86-64

glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl (495.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.8Windows x86

glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl (205.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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl (196.7 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl (120.5 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl (114.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.8manylinux: glibc 2.12+ i686

glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl (90.7 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl (95.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.8macOS 10.6+ Intel (x86-64, i386)

File details

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

File metadata

  • Download URL: glfw-2.5.1.tar.gz
  • Upload date:
  • Size: 30.4 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.5.1.tar.gz
Algorithm Hash digest
SHA256 90e29f3b2aacffcb9572ccb62cce53e3b9ae3c7ac9b6f60a32eaedac60f6a1ed
MD5 c55d5c1e918c98bd8f378069a855435a
BLAKE2b-256 9e74e2bc8a26243b597a743aa81a36cc6692d7b8df85dddaaed8bc9a591c15a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
  • Upload date:
  • Size: 491.9 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
Algorithm Hash digest
SHA256 8ebec84608c59f8b96a4094016a10e94ba69d0c31584142630aebc0e6de32d39
MD5 16f4267767066706d1ffa766fffa066b
BLAKE2b-256 46dff098e7a50ee01012c80a13f8a50ecbfc66f1b6249cafd4cf505477a7be7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
  • Upload date:
  • Size: 495.9 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
Algorithm Hash digest
SHA256 d49fbcf6ab250cfd728fd86d4918e5a76813437c4ee2271d342439ae8362f7ca
MD5 cfa5a03612866cd91635c35b8a3cbfbb
BLAKE2b-256 98da1c1ba7e6924e386cbd5c303aa752c04d5ef9ece59aa9b3183fcb2e000f5e

See more details on using hashes here.

File details

Details for the file glfw-2.5.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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 085e36ab9325597304c975a89e65f96d852004fa98858e2f2bbebdf1c1e6fa19
MD5 877fd0e31ba5e6aeb3585f0d8c6deaa4
BLAKE2b-256 7a08698148cc3ece28eb404ca42312edbf05399e99d83d1cf2d0613c05ac13c4

See more details on using hashes here.

File details

Details for the file glfw-2.5.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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f0ec60d6f9d20de06f2a201c794e974dcd060531720ed62f7ccd2eb0a3fa9b1f
MD5 55d0f05f5ee8a39293cd3bc839a31fb6
BLAKE2b-256 8918e423afacb1cd32cf871979f78b296171d2e9d8806f68e4cc775ce870e90f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 120.5 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 367ab2eced3961d801ff548b9e48267f5706e650012aab7b40f4cee5cbcdf160
MD5 ebeacbccb9c2d5db9113b75d5fbdac88
BLAKE2b-256 e6e17dc2d17185dcf9ed41c3932e946a585676f1b31751e7021fca60fd450e75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 114.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, 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 9861b3a9f805020a73a1cb5d2592cce6f02884343344181eaa00ac46529eff5f
MD5 0753e44f217465b2406a2a855d322f79
BLAKE2b-256 01c9fde44456655a1b84caa1da674c647dd6f9015c95da2b48184b66682b99c2

See more details on using hashes here.

File details

Details for the file glfw-2.5.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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 90.7 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cdae6b7f024e6a18d16ab9f4a822fc32e7bb6a85e3cd28e68454425e702d0777
MD5 38866faf34b5fecfe39fb72c83233083
BLAKE2b-256 03a2521d380a98b9456fb0320a9c5c9115ca7df52b41253bd6efd42a2d14c4b3

See more details on using hashes here.

File details

Details for the file glfw-2.5.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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 95.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, 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.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 eef9a5781bb9ac74674beffd9f78b088b8c58de1b49e919e670cab80e042539d
MD5 f81af88c03882198e89ee2189b4819af
BLAKE2b-256 a45da3d153363f3f0c0bc35bf9cfdab335d6b4f61329d4dfb65d65c3b218d80e

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