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, set it to ‘warn’ instead to issue warnings or set it to ‘log’ to log it using the ‘glfw’ logger)

  • 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.10.0.tar.gz (25.9 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.10.0-py2.py3-none-win_amd64.whl (492.4 kB view details)

Uploaded Python 2Python 3Windows x86-64

glfw-1.10.0-py2.py3-none-win32.whl (496.5 kB view details)

Uploaded Python 2Python 3Windows x86

glfw-1.10.0-py2.py3-none-manylinux2010_x86_64.whl (118.4 kB view details)

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

glfw-1.10.0-py2.py3-none-manylinux2010_i686.whl (112.6 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.12+ i686

glfw-1.10.0-py2.py3-none-macosx_10_6_intel.whl (99.8 kB view details)

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

File details

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

File metadata

  • Download URL: glfw-1.10.0.tar.gz
  • Upload date:
  • Size: 25.9 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.10.0.tar.gz
Algorithm Hash digest
SHA256 1bf790992c922923a27bb3d07b00faee97c95dc214708ea7ff1e0c8e22fc6276
MD5 0ff2fd28b9a8673b74795eac782ef0b8
BLAKE2b-256 04f4938380ed7d954262f39a83e83a250228f8802806f5599deca0743c9e9f8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.10.0-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 492.4 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.10.0-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 aecbaa7d09065f326a992aa6ba073c836b2e289a3d98a4bf2a041b314703087e
MD5 5423cb2e1ea731373f0a3af295932b38
BLAKE2b-256 02411a9f17d7b388e2f2c0ed547b6a8dbfb2cab3f388925edc92353a1869230e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.10.0-py2.py3-none-win32.whl
  • Upload date:
  • Size: 496.5 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.10.0-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 1528d20d6e04e377009ceaba3af3f8568bf299b12c99d1bc97bacd9041ebdd6e
MD5 73ea0e737d3e4e12da3a16d3e5b81ec9
BLAKE2b-256 9198f6a6406893fc745ddd9218f55aad94458ab45ae0102d828735a2d31fb909

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.10.0-py2.py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 118.4 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.10.0-py2.py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a15b6ca6ddf180b3aad4c05f17d763e7680f1000a370cfd2c9828a5995a8d2ec
MD5 7a57e0c49f5c3ccd75d28773ec85ce98
BLAKE2b-256 d526c294cdda6ba9191ef650c68562406a31b6092631ca6268aa0313f2f2dced

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.10.0-py2.py3-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 112.6 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.10.0-py2.py3-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 f3129a30333144da03958586653af6ce7cf78d411864688d3aa943e068453af3
MD5 a30be39899939a1bb949b22711f24d5d
BLAKE2b-256 90f839a5d0e94159929fab6077ad3f6a2349a4c61787e7ee9eddf96c5762e65a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.10.0-py2.py3-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 99.8 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.10.0-py2.py3-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 4601e33fd290be371c77627f44b816f38df987e914c36f43ede80fbba7a3cdd3
MD5 7784cf5e8ed84703684c91d17ce19015
BLAKE2b-256 2922600b22c98ccf64825ea8d084859ba155c4bd49b6a193ff269ddc8d7baa9f

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