FlorianRhiem / pyGLFW

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

Support to get native Window id's #39

Closed almarklein closed 4 years ago

almarklein commented 4 years ago

Hey! we're building a Python wrapper around the wgpu lib, and would like to use glfw as a lightweight alternative to provide a window.

However, to make things work, I need to provide wgpu with a native window id so it can create a surface object. It looks like glfw in principal supports this via e.g. glfwGetWin32Window.

Any idea how feasible it is to expose this via the Python API?

Thanks!

FlorianRhiem commented 4 years ago

Hey Almar, sure, I can add wrappers for the native access functions, though I won't get to it until after the holidays. Until then, you should be able to use the following as a quick wrapper for glfwGetWin32Window:

import ctypes
import glfw

glfw._glfw.glfwGetWin32Window.restype = ctypes.c_void_p
glfw._glfw.glfwGetWin32Window.argtypes = [ctypes.POINTER(glfw._GLFWwindow)]

def get_win32_window(window):
    return glfw._glfw.glfwGetWin32Window(window)
almarklein commented 4 years ago

No rush! That solution works like a charm, and I can get away with that just fine. Thanks a lot!

(I'll leave it up to you whether to close this or not.)

FlorianRhiem commented 4 years ago

I've added wrappers for all native functions as part of release 1.9.0.