FlorianRhiem / pyGLFW

Python bindings for GLFW
MIT License
233 stars 36 forks source link

Unable to set glfw.WAYLAND_APP_ID #78

Open bgribble opened 8 months ago

bgribble commented 8 months ago

This is in version 2.7.0 of the pyGLFW package, against version 3.4.0 of glfw.

I have manually searched for and removed any other versions of glfw on my (Debian unstable, amd64) machine.

The enum for WAYLAND_APP_ID is in the package, but the underlying C lib throws an error:

Python 3.11.8 (main, Feb 29 2024, 01:37:57) [GCC 13.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import glfw

In [2]: glfw.VERSION_MAJOR
Out[2]: 3

In [3]: glfw.VERSION_MINOR
Out[3]: 4

In [4]: glfw.VERSION_REVISION
Out[4]: 0

In [5]: glfw.init()
Out[5]: 1

In [6]: glfw.window_hint_string(glfw.WAYLAND_APP_ID, "mfp")
/home/grib/devel/mfp/.virtual/lib/python3.11/site-packages/glfw/__init__.py:914: GLFWError: (65539) b'Invalid window hint string 0x00026001'
  warnings.warn(message, GLFWError)

In [7]: glfw.window_hint_string(glfw.X11_CLASS_NAME, "mfp")

In [8]: glfw.window_hint_string(glfw.X11_INSTANCE_NAME, "mfp")

From looking at the GLFW source that error appears to come from falling through the switch statement just above, which for version 3.4.0 does include WAYLAND_APP_ID. So I thought that maybe the Python bindings were pointing to an incorrect version of libglfw, but I can't find another one on my system.

I do notice that glfw.get_version() returns (3, 3, 9) rather than the expected (3, 4, 0) so maybe that IS the problem somehow?

FlorianRhiem commented 8 months ago

Hey @bgribble,

you are using GLFW 3.3.9, not GLFW 3.4, so that's why that case isn't handled by GLFW. The confusion is understandable, though:

This package provides wrappers for GLFW 3.4, however due to buildsystem incompatibilities, I cannot build 3.4 to be included in the wheels (short version, wheels have specific build system images, which in are too old for features used by 3.4, some more info in issue #77 ), so instead I provide the latest version I can still build for them, 3.3.9.

When/if those issues get resolved, I will update the package with GLFW 3.4. Until then, if you wish to use those newer features, download GLFW from glfw.org, either as a pre-built binary or as source code to compile for yourself, or use a version from a package manager.