Thread overview
I'VE DONE IT! D3DX9 IN D!
Jan 05, 2005
Matthew
Jan 05, 2005
Walter
Jan 05, 2005
pragma
Jan 05, 2005
John Reimer
How I did it (and other replies)
Jan 06, 2005
John Reimer
Jan 06, 2005
Walter
January 05, 2005
I got D3DX9 to work in D!

Oh yes!  Indeed!

Using the Clootie Graphics Libs, a set of directx libs converted to the OMF format, and a header file written by Mr. Tomino (Japanese DirectX guy), I have FINALLY gotten D3DX to work!

I am.. ecstatic!

If anyone is interested, feel free to ask!  :)


January 05, 2005
Well done! :-)

"Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:crfhhu$fbo$1@digitaldaemon.com...
>I got D3DX9 to work in D!
>
> Oh yes!  Indeed!
>
> Using the Clootie Graphics Libs, a set of directx libs converted to
> the OMF
> format, and a header file written by Mr. Tomino (Japanese DirectX
> guy), I
> have FINALLY gotten D3DX to work!
>
> I am.. ecstatic!
>
> If anyone is interested, feel free to ask!  :)
>
> 


January 05, 2005
Great! Can you write up a brief "How I Did It" so that others can follow in your footsteps and post it here?


January 05, 2005
In article <crfhhu$fbo$1@digitaldaemon.com>, Jarrett Billingsley says...
>
>I got D3DX9 to work in D!
>
>Oh yes!  Indeed!
>
>Using the Clootie Graphics Libs, a set of directx libs converted to the OMF format, and a header file written by Mr. Tomino (Japanese DirectX guy), I have FINALLY gotten D3DX to work!
>
>I am.. ecstatic!
>
>If anyone is interested, feel free to ask!  :)
>
>

Excellent work!  Now D has SDL *and* DX bindings.  W00t!

- Pragma (EricAnderton at yahoo)


January 05, 2005
On Tue, 04 Jan 2005 20:58:09 -0500, Jarrett Billingsley wrote:

> I got D3DX9 to work in D!
> 

I'm confused.  This is great, but haven't these bindings been available for awhile?  svn.dsource.org/svn/projects/bindings...  perhaps it's the omf libraries have been what's lacking.
January 06, 2005
Okay, here's how I did it:

1) Downloaded the Clootie graphics libs from http://clootie.narod.ru/.  I just downloaded the C++ builder DX92 libs and DLLs files.

2) Placed the libs in my libs folder, placed the DLLs (two of them) in the same folder as my program.  Renamed d3dx92ab.dll to d3dx9.dll (otherwise it complains).

3) It turns out that the Direct3D header file was not Y. Tomino's header file, but Hideki's.  Downloaded from http://hp.vector.co.jp/authors/VA031566/d_direct3d9/index.html (d3d9.d).

4) At the bottom of d3d9.d, removed the block of code with the "Direct3DInit()" and "Direct3DCreate9()" functions.  Replaced them with

extern (Windows) export IDirect3D9 Direct3DCreate9(UINT SDKVersion);

5) Created a .def file for my program, and in it, placed the following line of text: _Direct3DCreate9@4=d3d9.Direct3DCreate9

6) Some functions, like D3DXCreateSprite(), already have the "extern(Windows) export" in front of them.  For these, I just had to add a declaration in the .def file like for Direct3DCreate9.

7) Most functions, like D3DXCreateTexture(), have definitions like the following:
HRESULT function(
        IDirect3DDevice9         pDevice,
        UINT                      Width,
        UINT                      Height,
        UINT                      MipLevels,
        DWORD                     Usage,
        D3DFORMAT                 Format,
        D3DPOOL                   Pool,
        IDirect3DTexture9*       ppTexture) D3DXCreateTexture;

This simply defines a function pointer to be used with GetProcAddress.  Since we're importing the functions rather than explicitly loading the DLL, the declaration needs to be changed to:

extern(Windows) export HRESULT D3DXCreateTexture(
        IDirect3DDevice9         pDevice,
        UINT                      Width,
        UINT                      Height,
        UINT                      MipLevels,
        DWORD                     Usage,
        D3DFORMAT                 Format,
        D3DPOOL                   Pool,
        IDirect3DTexture9*       ppTexture);

Then the appropriate declaration can be added in the .def file.  (This is why I asked how to call an unmangled function - the functions in the directx libs are unmangled, and I can't seem to get the D compiler to look for an unmangled C function.  So we have to use the .def file to translate.)



Then I just used the functions as in C++.

I suppose it would be simpler to use extern(C) instead, which would eliminate the need for the "@4" or whatever in the .def file function definitions.  But they still need the preceeding underscore.


There have been several bindings to DirectX and Direct3D before, but as far as I know, never to D3DX, simply because.. well, it seems to be unusually difficult.  There is still, AFAIK, no way to statically link D3DX in anything but MS C++ compilers.

But oh well - MS itself said that it is going to move D3DX out into a DLL in future versions of DX, so we're ahead of the times, I guess ;)

January 06, 2005
I suppose it would be simpler to use extern(C) instead, which would eliminate the need for the "@4" or whatever in the .def file function definitions.  But they still need the preceeding underscore

Just tried this - and no, it doesn't seem to work.  Looks like we're stuck with extern(Windows) and the @number function defs.

January 06, 2005
Jarrett Billingsley wrote:
>  There have been several bindings to DirectX and Direct3D before, but as far as I know, never to D3DX, simply because.. well, it seems to be unusually difficult.  There is still, AFAIK, no way to statically link D3DX in anything but MS C++ compilers.
>  But oh well - MS itself said that it is going to move D3DX out into a DLL in future versions of DX, so we're ahead of the times, I guess ;)

Ah yes, I now recall the D3DX issue.  I remember running across this problem while trying to convert a project from MS C++ to gnu mingw.  It was very annoying D3DX was only available in a MS static lib form (if I recall, D3DX was only released as a DLL in the debug version).

Great to see you found a workaround for dmd.  Nice work!
January 06, 2005
Thanks!