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

  • structs have been replaced with Python sequences

  • 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

  • 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

For Windows users, the GLFW shared library is included in the Python wheels. Linux and macOS users need to install the library themselves 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 on Linux and DYLD_LIBRARY_PATH on macOS). 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.5.1.tar.gz (17.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-1.5.1-py2.py3-none-win_amd64.whl (55.2 kB view details)

Uploaded Python 2Python 3Windows x86-64

glfw-1.5.1-py2.py3-none-win32.whl (51.5 kB view details)

Uploaded Python 2Python 3Windows x86

File details

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

File metadata

  • Download URL: glfw-1.5.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for glfw-1.5.1.tar.gz
Algorithm Hash digest
SHA256 4c7a3c158c216ac482f706bcf9c2f2e5b6ab3edddf7232236c93dccca6ac26b3
MD5 4daeecebfba79a265617091f6beb6bfa
BLAKE2b-256 84595ddd23f55ccff106eec8d3bf34d1a6351bfd23d5c2cd357c2e9edc6f8e76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for glfw-1.5.1-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6936a335d757955cb932c60002a31876814196ae6f7cf5c6e88064b36956f83d
MD5 7ec5870e30b3bd45bb773be656e3d49d
BLAKE2b-256 0d1b39cc107268b42f7f528bfd52feaf631d42b2d971c47ab95d28c65f3e196c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: glfw-1.5.1-py2.py3-none-win32.whl
  • Upload date:
  • Size: 51.5 kB
  • Tags: Python 2, Python 3, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for glfw-1.5.1-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 bb82ab8ba3c41326ffe6b0da649ea77f6540d6c74332653c3cfd7c0c19f39821
MD5 8a9b3d2567b84b594d86b5d31591c3d5
BLAKE2b-256 4351d8957205cb687c757a472fd1d0801527c8ee463dd192c535ac92a141bd3c

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