News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Working with D3DX10

Started by satpro, June 07, 2016, 05:58:07 AM

Previous topic - Next topic

satpro

I've been messing around with DirectX 10 lately and things are going well.  I did run into a snag with the D3DX10 dll, and that took a while to figure out.  I thought I would just post the solution here because I haven't really seen it anywhere else.


As we know, you can use a dll by just listing it in the GoLink command line.  Well, I tried using d3dx10.dll and it just kept crashing, no matter what I did, or what calling convention I tried.  The function calls in D3DX10 are just regular old "invoke" calls after all, but nothing clicked until I used file "d3dx10_43.dll", the newest of the Dx10 updated files from 2010.  The 10.1 extensions are in there, too.


That's it!  It was that easy.  After the initial Eureka! moment I thought about trying the other earlier files (_33 thru _42) to be thorough, but then asked myself, "Why?"  The Microsoft Dx10 header files are a bit easier on the "adaptation" nerves than Dx 11 or D2D1, etc. (less HLL soup to wade through) so that's why I'm using Dx10 right now instead of the newer ones.  I would add that dxgi.dll is just straight-up COM.


The D3DX library itself includes many important tasks that make using DirectX so much easier, and it's really quite easy to use.  So I hope this helps anyone who may have or who will face this themselves.  Several calls distinguish ansii or uni (A or W) so your include file might define a conversion (just like in regular Windows calls) to eliminate that issue.   :t


Also, here is a SafeRelease macro I came up with to release interface pointers.  Use it like so:    SafeRelease(ID3D10Device, ppDevice)
The params are (formal interface name, your interface ptr variable).





SafeRelease(%interface, %pptr) MACRO
  cmp D[%pptr], NULL
  je >


   push [%pptr]                 ;push the interface ptr contents
   mov eax, [%pptr]             ;copy interface contents to register
   mov eax,[eax]                ;get the ptr stored at that address
   add eax, IUnknown.Release    ;add the distance to method in COM vtable
   call [eax]                   ;call function at effective address


  mov D[%pptr], NULL
:
ENDM