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.5.tar.gz (30.3 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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl (492.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl (496.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl (207.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.8

glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl (198.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.8

glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl (121.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.8manylinux: glibc 2.12+ x86-64

glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl (115.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl (92.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 11.0+ ARM64

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

File details

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

File metadata

  • Download URL: glfw-2.5.5.tar.gz
  • Upload date:
  • Size: 30.3 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.5.tar.gz
Algorithm Hash digest
SHA256 a282a2a742a0d01734dbde746dfc8f696f76373520494e40f39f60615408426d
MD5 e837858dd801685d2c404a9f8a785981
BLAKE2b-256 9a43fbb2450c6ea64f9b7a7204d6fc6fff8930bb9f7bbfc94cd02b6e9a74a575

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
  • Upload date:
  • Size: 492.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
Algorithm Hash digest
SHA256 1e9fb75db4acbfc25ae3e7ab5b3cb1b760e927a2be49200cfe8ab7162db33df2
MD5 7eb8e3a1e8fba354fd7993245c8f1de6
BLAKE2b-256 91c3214dd00a083eea66a2eeaef0f62eac417fefdf7758702fa9420995c9b0bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
  • Upload date:
  • Size: 496.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
Algorithm Hash digest
SHA256 09ef5c8ab888d58db9e607af5525088db24fe43a39649f24a3447dad0f7a174d
MD5 d69b453eff583653ddf4eb00d5a34399
BLAKE2b-256 5c84393d16a5650e652fe9188c7740b5f36b175d6bc40c0f53792c48aba10bc4

See more details on using hashes here.

File details

Details for the file glfw-2.5.5-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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d73640474ee0fdfcb32dc255ba41ee932a5ed924cbf62c53577d6b26c204dd1
MD5 1244dc3efed5cbbe50a8560e774636e9
BLAKE2b-256 3a9062722c249ddfc6156b86cc3f9f32db0f5d95b79d57ae912a59285e43da57

See more details on using hashes here.

File details

Details for the file glfw-2.5.5-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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5ab10ad838d6096eeeb778a291aab3893eeb31abe8e356f8a8f0e338cd8d25c9
MD5 f680bf809231de07868632cb8291afb5
BLAKE2b-256 77908f6ae31cd5a4104a0bec1d5bebb583c140218203c68898c5dd2045046e4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 121.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, 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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3301de161e234fcc5f182b5157c3177f8e23ef35893060c47f12770c11a60932
MD5 8c0190ad1d41102fe2d8b8097202b181
BLAKE2b-256 a723e0400fb6ee6a377de676a46c9b8215638253bb8ef903a9a2a42cc0657e48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 115.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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 9508e840f25e72e8efbdcc772b87b4c35cacd66c1c9e6bd0bbb08cded070ccc4
MD5 72fdba5bbf7a01133a78a52139ef1cf3
BLAKE2b-256 ee1fa7be28ea0fd26cb1f47ae0d0c1051e53abf2aab361e493bf3b34551657eb

See more details on using hashes here.

File details

Details for the file glfw-2.5.5-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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 92.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 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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a33f391a22952de524c694a22cf0614d2949503519f2f7f58b0a3d2defdd9be
MD5 a41655bab93b8e063641777e3c235139
BLAKE2b-256 d8e9bee0464fd90de25ee2a3d8feec3c86c9e84c5de9305b97620dc39c6746b1

See more details on using hashes here.

File details

Details for the file glfw-2.5.5-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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 96.2 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.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 1c6ffe20350bd7931c4954720fbef498c2e9bce43ebd719c41de9e87c3fb7173
MD5 0e8b84e61c2b38939063b34eb18b60fb
BLAKE2b-256 d6a8cf76b080127fde5017772e7a292fd10227b0e76847214440079774a6dabd

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