Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 native access doesn't seem to build #16

Open
AndrejMitrovic opened this issue Sep 2, 2022 · 3 comments
Open

Win32 native access doesn't seem to build #16

AndrejMitrovic opened this issue Sep 2, 2022 · 3 comments

Comments

@AndrejMitrovic
Copy link

Hi!

I've tried using apinative.d as I need access to the native window handle. But I get import errors, and also linking errors.

This patch seems to fix it:

diff --git a/source/glfw3/apinative.d b/source/glfw3/apinative.d
old mode 100644
new mode 100755
index f2c372b..d364e9d
--- a/source/glfw3/apinative.d
+++ b/source/glfw3/apinative.d
@@ -78,6 +78,8 @@ extern(C): @nogc: nothrow: __gshared: export:
  *************************************************************************/

 version (GLFW_EXPOSE_NATIVE_WIN32) {
+import glfw3.api;
+import core.sys.windows.windows;
 /** Returns the adapter device name of the specified monitor.
  *
  *  Returns: The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
@@ -470,4 +472,4 @@ int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* b
  *  Ingroup: native
  */
 OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
diff --git a/source/glfw3/win32_window.d b/source/glfw3/win32_window.d
old mode 100644
new mode 100755
index 2e909d4..2040409
--- a/source/glfw3/win32_window.d
+++ b/source/glfw3/win32_window.d
@@ -2133,6 +2133,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow* wind
     return err;
 }

+extern(C): @nogc: nothrow: __gshared: export:

 //////////////////////////////////////////////////////////////////////////
 //////                        GLFW native API                       //////
@@ -2142,4 +2143,4 @@ HWND glfwGetWin32Window(GLFWwindow* handle) {
     _GLFWwindow* window = cast(_GLFWwindow*) handle;
     mixin(_GLFW_REQUIRE_INIT_OR_RETURN!"null");
     return window.win32.handle;

Not sure it's the best way to do it. Let me know if you want me to PR it. Cheers~

@dkorpel
Copy link
Owner

dkorpel commented Sep 2, 2022

Thanks for reporting, I'm on it. I've added the imports, but I'm not sure about the extra annotations.
__gshared: and extern(C) should be redundant, not sure what export does, and the lack of @nogc nothrow should not be a problem when you use the prototype from apinative.d, but I'll have to look into it when I boot on Windows.

@AndrejMitrovic
Copy link
Author

I think I might be mistaken about the linker issues. I thought linking failed, but it's just some strange warning:

LINK : warning LNK4217: symbol 'glfwGetWin32Window' defined in 'app.obj' is imported by 'app.obj' in function <long-mangled-name-here>

@schveiguy
Copy link

not sure what export does

I've run into this. export specifies on Windows that this is part of the exported DLL data symbols. If you don't include export, it won't link (for DLLs). this is not needed for functions for some reason. See e.g. I had to do this here: schveiguy/raylib-d@6c58d34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants