I would like to call the function CreateDXGIFactory1. This is the code I currently have:
import jdk.incubator.foreign.ResourceScope.newConfinedScope
import win32.mapped.com.IDXGIFactory1_J
import win32.mapped.constants.Constants.S_OK
import win32.pure.IDXGIFactory1
import win32.pure.Win32.CreateDXGIFactory1
fun main() {
System.loadLibrary("Dxgi")
val scope = newConfinedScope()
val riid = IDXGIFactory1_J.REFIID() // crashes
val ppFactory = IDXGIFactory1.allocate(scope)
val hr = CreateDXGIFactory1(riid, ppFactory)
if (S_OK != hr) {
throw IllegalStateException("Result: $hr")
}
}
I think this is the correct way, but if this is wrong please let me know. I could not find any examples of jwin32, which would be helpful to get started.
When running the code I get the following output:
WARNING: Using incubator modules: jdk.incubator.foreign
Exception in thread "main" java.lang.UnsatisfiedLinkError: unresolved symbol: IID_IDXGIFactory1
at win32.pure.RuntimeHelper.requireNonNull(RuntimeHelper.java:39)
at win32.pure.Win32_22.IID_IDXGIFactory1$SEGMENT(Win32_22.java:2734)
at win32.mapped.com.IDXGIFactory1_J.REFIID(IDXGIFactory1_J.java:64)
at MainKt.main(Main.kt:12)
at MainKt.main(Main.kt)
Any idea what is going wrong here? Looks like the library is not loaded correctly, but I do not know why,
I am using openjdk-17-panama+3-167_windows-x64_bin.
I cloned the jwin32 project, and added the line #include <dxgi.h> to config.h. Then I ran the generate and build commands and included the generated jar in my project.
Help would be appreciated. Your project looks amazing.