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 exceptions if no error callback is set (use glfw.ERROR_REPORTING=False to disable this)

  • 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, please follow the steps for Linux below, to build and install GLFW yourself, then place it in one of the library search paths or set PYGLFW_LIBRARY to the location of the library.

Linux

You will need to install the GLFW shared library yourself and should compile 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.

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-1.9.1.tar.gz (25.5 kB view details)

Uploaded Source

Built Distributions

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

glfw-1.9.1-py2.py3-none-win_amd64.whl (492.0 kB view details)

Uploaded Python 2Python 3Windows x86-64

glfw-1.9.1-py2.py3-none-win32.whl (496.1 kB view details)

Uploaded Python 2Python 3Windows x86

glfw-1.9.1-py2.py3-none-manylinux2010_x86_64.whl (118.0 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.12+ x86-64

glfw-1.9.1-py2.py3-none-manylinux2010_i686.whl (112.2 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.12+ i686

glfw-1.9.1-py2.py3-none-macosx_10_6_intel.whl (99.4 kB view details)

Uploaded Python 2Python 3macOS 10.6+ Intel (x86-64, i386)

File details

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

File metadata

  • Download URL: glfw-1.9.1.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1.tar.gz
Algorithm Hash digest
SHA256 c3203f1252038bc62aa0aa5cfbe99dd8539c8cb987c08f2f86aaf79ff0d214d8
MD5 a51deea23f56f4ba2c2c6722a65800d4
BLAKE2b-256 d3d5030432b22e95d7889e508bee234a455ac93cc391672c837541bfd1cad80f

See more details on using hashes here.

File details

Details for the file glfw-1.9.1-py2.py3-none-win_amd64.whl.

File metadata

  • Download URL: glfw-1.9.1-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 492.0 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f71b44371201fe6543cd8f41e527359e117e8f0fbbc310538ec4f38a56080126
MD5 6300a23c0714582cb7022b8070815740
BLAKE2b-256 0726d33bb4af12fc26b53aab8e939174b8b6c79a0b6ee9df7c33eb635c0241a0

See more details on using hashes here.

File details

Details for the file glfw-1.9.1-py2.py3-none-win32.whl.

File metadata

  • Download URL: glfw-1.9.1-py2.py3-none-win32.whl
  • Upload date:
  • Size: 496.1 kB
  • Tags: Python 2, Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 d34c90f970532df5eb66bd1e6c73e0f6fd129aef4d1364c8dc9236816ca687d9
MD5 42eb671d84ee2c544f7a62f1d56f7109
BLAKE2b-256 d573647d9cdf76337ed54b9cc3cfa71d6660548342478eb04bdf91639b8df215

See more details on using hashes here.

File details

Details for the file glfw-1.9.1-py2.py3-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: glfw-1.9.1-py2.py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 118.0 kB
  • Tags: Python 2, Python 3, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1-py2.py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 47449d64b0ffca7eaec51fa48231323b6eb8fb26bcb67a1b804269f1da48eeb6
MD5 ad956719bd24cfe768916aae9d549989
BLAKE2b-256 2cb18d555f78aab52650ae209b54a480fab1d653ba87edffd38b61bb1665a3be

See more details on using hashes here.

File details

Details for the file glfw-1.9.1-py2.py3-none-manylinux2010_i686.whl.

File metadata

  • Download URL: glfw-1.9.1-py2.py3-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 112.2 kB
  • Tags: Python 2, Python 3, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1-py2.py3-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 b8e4b9a03cb3f9303c67dd4568f1d57bc363854943fe2655822a12c7cafa92f0
MD5 a3b52907ffb2994fc648ecf902c9010b
BLAKE2b-256 adb92a07bc74502611446cadab3115e67d175f8691947d504bdb3157091bb8a0

See more details on using hashes here.

File details

Details for the file glfw-1.9.1-py2.py3-none-macosx_10_6_intel.whl.

File metadata

  • Download URL: glfw-1.9.1-py2.py3-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 99.4 kB
  • Tags: Python 2, Python 3, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/28.8.0 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.13 Darwin/16.7.0

File hashes

Hashes for glfw-1.9.1-py2.py3-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 3800e9521ac205a06b7a2d3b84b9a87d96d1627a0a38bc84d6bfc91cbae69d9a
MD5 dd1d40f10ebe674c8faf8348cf59d173
BLAKE2b-256 ed5d9ba6dea01ca88f824e7c89ecbc0cd0f67a9948366d4e8974a658137c07f5

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