FlorianRhiem / pyGLFW

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

get the GLFWwindow* value? #47

Closed welch closed 4 years ago

welch commented 4 years ago

Feels like I'm missing something obvious here, but how do I get the pointer value that I'd pass to some other library wanting a GLFWwindow*?

welch commented 4 years ago

looking at issue #39, and recalling i am on a mac, this seemed promising: winid = glfw._glfw.glfwGetCocoaWindow(window)

but now I'm told I need a NSView*, which I would get like this in obj-c:

NSWindow* win = (NSWindow*)glfwGetCocoaWindow(glfwWindow);
    NSView* view = [win contentView];
    return view;

likely I've left the scope of this package, I'll leave this up anyway.

FlorianRhiem commented 4 years ago

The code you mentioned was for the NSWindow* or the NSView*. If you actually need the GLFWwindow* it's much simpler. When you create a GLFW window with this package using glfw.create_window(...), what you get in return is the GLFWwindow* as a ctypes Pointer to a dummy _GLFWwindow struct. You can use ctypes.cast to cast this pointer to any other pointer type you want, depending on the package that you want to pass it to.