Can I include the included glfw2.7 header in native extensions?

If so what’s the correct file / folder path? How can I properly call glfw functions?

Including a copy of a glfw 2.7 glfw.h works, but that seems dodgy… is that okay to do? Is the one Defold uses vanilla 2.7 or are there significant modifications?

The answer to the question is that we cannot guarantuee any API that’s not in the Defold SDK.
We might change the current function signatures in an API (e.g. via updates or fixes), their functionality or we might remove the API altogether.

Relying on existing, hidden, API’s is always very volatile, it can break your code from one release to another, and I would not recommend it.

That said, yes, we currently use a modified GLFW 2.7 version. Our modifications are additional functions (taken from GLFW 3).

3 Likes

@Pkeod What functionality do you need access to? Perhaps we can expose it via the SDK?

What is needed right now that I’m not sure of the right way to do is to be able to properly detect if the mouse cursor is within the client area of the window on Windows (and other OS). The issue it’s related to is that if you hide mouse on Windows with using ShowCursor(0) then it keeps the mouse hidden within the client area and the edge of the window and on the title bar which makes interacting with the window to resize it or the title bar to move the window annoying. The proper way to do this is something like suggested here https://stackoverflow.com/questions/5629613/hide-cursor-in-client-rectangle-but-not-on-title-bar

I remembered GLFW has hide/show mouse function and might have it the proper way handling for still showing in window title and edges of window.

I tested another method with getting mouse position, client position and size to determine if cursor is within client window but it doesn’t seem to work right https://github.com/subsoap/defos/commit/89eeb3982a0ba8c184e39e4ad509463cf087b289

If all functionality DefOS provides could be added to main Defold that would probably be for the best. Even if we write all native code there will still be likely changes which will break down the road.