I have just recently begun implementing the humble start of a Direct3D 11 binding for LWJGL 3.
This is going to be a bit more involving than the OpenGL binding, because Direct3D is an object-oriented API and meant to be used via C++.
Therefore, I am planning to map the most necessary C++ classes in Direct3D 11 to Java interfaces or classes.
For example, ID3D11Device will become a real Java interface with virtual methods.
Each Java class and interface shall have the same methods that you can invoke on them like the virtual functions in its Direct3D C++ class.
Regarding Win32 API for window creation, LWJGL 3 already has everything for that. So, window creation code is going to be done in Java with the Win32 API functions, like in
WindowsDisplay and
WGLDemo.
Just like with OpenGL, the goal for the D3D binding is to make a Direct3D application written in Java with LWJGL 3 feel like it has been written in C++. This allows for easy transition between the two languages and to easily apply examples and tutorials to LWJGL 3.
I am not planning on using the Kotlin generator approach or SWIG during the very early development stages.
That's because I want to get a feeling for what it looks like mapping C++ to Java, and how an "optimal" generator and template would look like to support that in a good way.
Luckily, there are very few things in C++ that actually need mapping to Java:
1. Out parameters for class and struct pointers
Just like how LWJGL 3 does it, the d3d11 binding will use PointerBuffer for that.
2. Value structs as input parameters
Here, the struct will be represented by a Java class that will contain a method to write it into a ByteBuffer.
That ByteBuffer is then handed to the JNI function and cast there to the appropriate struct type.
3. Virtual functions on objects
These will get the "this" pointer as long address. Each Java instance of a d3d11 class will have a "long address" field which holds the address at which d3d allocated the instance in memory.
In the JNI function, this address will then be reinterpreted as a pointer to an instance of the corresponding C++ class.
4. Enums and flags
Enums that are not flags (cannot be bitwise OR'ed) will be represented as Java enums for typesafety. Since Direct3D is more typesafe than OpenGL by design we can gain something from it here.
Flags that can be bitwise OR'ed, like DXGI_SWAP_CHAIN_FLAG, will get a single Java interface with int constants.
All in all Direct3D 11 is a pretty clean API. Hopefully will be fun to get something started with Java and LWJGL 3 in little time.
Regarding feature-set and milestones, I will be going along the lines provided by the
MSDN Direct3D Tutorial Win32 Sample.
I'll let you know when I have Tutorial01 working with LWJGL 3.
Cheers,
Kai