This release is a pre-release and may not be stable for production use.
GLFW for Py++
a Py++ library for GLFW
Examples
Opening a window
With this library installed, the following Py++ code works to open a window. This is the typical example given in the docs for the glfw C++ and Python libraries.
from pypp_glfw import glfw, GLFWwindowPtr
from pypp_python import to_c_string, NULL
def glfw_test():
if not glfw.init():
raise Exception("Failed to initialize GLFW")
window: GLFWwindowPtr = glfw.create_window(
640, 480, to_c_string("Hello World"), NULL, NULL
)
if not window:
glfw.terminate()
raise Exception("Failed to create GLFW window")
glfw.make_context_current(window)
while not glfw.window_should_close(window):
# Render here, e.g. using pyOpenGL
glfw.swap_buffers(window)
glfw.poll_events()
glfw.terminate()
if __name__ == "__main__":
glfw_test()
Opening a window and handling inputs
from pypp_glfw import glfw, GLFWwindowPtr
from pypp_python import to_c_string, NULL
def key_callback(
_window: GLFWwindowPtr, key: int, _scancode: int, action: int, _mods: int
):
if action == glfw.PRESS:
print(f"Key {key} pressed")
elif action == glfw.RELEASE:
print(f"Key {key} released")
def mouse_button_callback(_window: GLFWwindowPtr, button: int, action: int, _mods: int):
if action == glfw.PRESS:
print(f"Mouse button {button} pressed")
elif action == glfw.RELEASE:
print(f"Mouse button {button} released")
def cursor_position_callback(_window: GLFWwindowPtr, xpos: float, ypos: float):
print(f"Mouse moved to ({xpos}, {ypos})")
def glfw_test_2():
if not glfw.init():
raise Exception("Failed to initialize GLFW")
window: GLFWwindowPtr = glfw.create_window(
640, 480, to_c_string("Hello World"), NULL, NULL
)
if not window:
glfw.terminate()
raise Exception("Failed to create GLFW window")
glfw.make_context_current(window)
glfw.set_key_callback(window, key_callback)
glfw.set_mouse_button_callback(window, mouse_button_callback)
glfw.set_cursor_pos_callback(window, cursor_position_callback)
while not glfw.window_should_close(window):
# Render here, e.g. using pyOpenGL
glfw.swap_buffers(window)
glfw.poll_events()
glfw.terminate()
if __name__ == "__main__":
glfw_test_2()
API
For the API, refer to pyGLFW.
Supported GLFW attributes and functions
Only the attributes and functions which are shown in the above examples are tested. However, its very likely that others will work also, and you will most easily find out by trying them in your code.
When you find an attribute or function which does not work, it would be really helpful if you submit a feature request with title support for glfw.<some_name>. Thanks in advance for if you do that.
Bug reports
Report bugs to the Issues tab on this github repo using the bug label.
Feature requests
Submit feature requests to the Issues tab on this github repo using the feature request label.
Metadata
Release files for pypp-glfw 1.0.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypp_glfw-1.0.0a0.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypp_glfw-1.0.0a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / pypp_glfw-1.0.0a0.tar.gz
| Download URL | pypp_glfw-1.0.0a0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da600103ddfb227525c8d28ef6f92ebde54951b456d0300b24136cfb76a48997
|
|
BLAKE2b-256 checksum How to use checksums |
7ad3af6fe3dee69f430c0b9760d292a9eabf795c6c3457f5e3d439bb69bb1f87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / pypp_glfw-1.0.0a0-py3-none-any.whl
| Download URL | pypp_glfw-1.0.0a0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1af72c4d9b5f1c0202b4f4fc46cc5b6ec7234f579b52201fc501514a6fdbee12
|
|
BLAKE2b-256 checksum How to use checksums |
7e7e24cf675a2e10228ea6e963b3c59c3652bf590b8d807bb0b450d0634b838d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|