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, 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.

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

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

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

glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl (111.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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl (99.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-1.11.1.tar.gz.

File metadata

  • Download URL: glfw-1.11.1.tar.gz
  • Upload date:
  • Size: 27.7 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-1.11.1.tar.gz
Algorithm Hash digest
SHA256 bcbe5ca473ad64e0d556f20babef778ae52a4f8d2035eedbe48af80ae0c679a6
MD5 337e3761b4dcf406605163f7d50f5971
BLAKE2b-256 e378a3d38ce67db2b4df75b3c95dc4cee0b8f32bfd211d5f5f6e4711830241fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
  • Upload date:
  • Size: 491.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, 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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl
Algorithm Hash digest
SHA256 ad99b4a4bac848fa963813ccc839e9311c563248772063f7874f8da4fbe5414f
MD5 5fd7b589e7cf6f5fc5f1bd19ddd0556e
BLAKE2b-256 5874f00ae2584543db7ce59d308fc7cd64ec5ae6f509ebb9f56ba226b1e9f0fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
  • Upload date:
  • Size: 495.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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win32.whl
Algorithm Hash digest
SHA256 39fa85aa27a5eb140efc90e23304388473733b98c6ee66c373c9b3e201ec6d7b
MD5 09d154a0068e1dac5a403a1a54fdf951
BLAKE2b-256 2f3be9636633b51066b872736f00b3bb48f283eb17921d100ede15adb70ef16d

See more details on using hashes here.

File details

Details for the file glfw-1.11.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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c967955b5b77fee562b3faaa538683c169319a6e68f78cd848f9f95c2dd5d15d
MD5 70e508f271782a13571e8d925ce67011
BLAKE2b-256 680330603dd2f3af440b41e481382c8b0f102de2c33f339b5ef1dee923260238

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 117.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, 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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0decb3cfe8f5a6df48134bd1ec4541863a0e24a93efa4da31f3f7c172681567c
MD5 9bf4a2ca63b7c00572d0fd69bbfd8321
BLAKE2b-256 035d2b9df8212b0c2b62654e580e70a1fc563a367e871af39269192a27a5c9ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
  • Upload date:
  • Size: 111.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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 abd6fba448a5b76d020f0c6e8d9906c685e8ab9db20f5ef33315bd00d931767a
MD5 7fb8d9ed4ca2e33e13462e1bc654d3de
BLAKE2b-256 46118bfb621fd8eae5c0f1314b970df7f14f972aba07a6675e09cd6b9a18bb5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 99.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-1.11.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 58571b8c87c4632bf7031c8e3508d668e9d4e4a7963ad26995e1db3615e31205
MD5 aa906e8aee0970d39a81d0949803148a
BLAKE2b-256 62a04b19910ef41815bc95bc41e11c73af472780d83bfd0e4fc7eaa0ea52ace4

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