Hey guys, I've been thinking about doing some D3D9 in assembly for fun and I noticed there wasn't an available include file. So I've started writing out the COM object definitions from the d3d9.h header file and I would appreciate it if someone could look over the IDirect3D9 definition I have so far. I would like to keep it consistant with the MASM COM stuff and hand it out when it's finished but I'm a newbie so I don't trust myself. Oh, any suggestions for speeding up the translation would be great since there are so many interfaces (As I write this the hugeness of the IDirect3DDevice9 interface is looming). Also, as far as interfaces that inherit from anoher interface, do put the functions from the inherited class into the derived class? Do they go before the other functions? For example, IDirect3DTexture9 inherits from IDirect3DBaseTexture9 which inherits from IDirect3DResource9 which inherits from IUnknown. When I'm adding the functions into the IDirect3DTexture9 structure, do I first write the IUnknown functions, then all the IDirect3DResource9 functions, IDirect3DBaseTexture9, and finally add the IDirect3DTexture9 functions at the end? Or do I simply write the specific IDirect3DTexture9 functions?




; PROTOTYPES -------------------------------------------------------------------------------------

QueryInterface_Proto typedef PROTO :DWORD, :DWORD, :DWORD
AddRef_Proto typedef PROTO :DWORD
Release_Proto typedef PROTO :DWORD
RegisterSoftwareDevice_Proto typedef PROTO :DWORD, :DWORD
GetAdapterCount_Proto typedef PROTO :DWORD
GetAdapterIdentifier_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD
GetAdapterModeCount_Proto typedef PROTO :DWORD, :DWORD, :DWORD
EnumAdapterModes_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
GetAdapterDisplayMode_Proto typedef PROTO :DWORD, :DWORD, :DWORD
CheckDeviceType_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
CheckDeviceFormat_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
CheckDeviceMultiSampleType_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
CheckDepthStencilMatch_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
CheckDeviceFormatConversion_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
GetDeviceCaps_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD
GetAdapterMonitor_Proto typedef PROTO :DWORD, :DWORD
CreateDevice_Proto typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD


; END PROTOTYPES ----------------------------------------------------------------------------------

; FUNCTION POINTERS -------------------------------------------------------------------------------

QueryInterface_Pointer typedef ptr QueryInterface_Proto
AddRef_Pointer typedef ptr AddRef_Proto
Release_Pointer typedef ptr Release_Proto
RegisterSoftwareDevice_Pointer typedef ptr RegisterSoftwareDevice_Proto
GetAdapterCount_Pointer typedef ptr GetAdapterCount_Proto
GetAdapterIdentifier_Pointer typedef ptr GetAdapterIdentifier_Proto
GetAdapterModeCount_Pointer typedef ptr GetAdapterModeCount_Proto
EnumAdapterModes_Pointer typedef ptr EnumAdapterModes_Proto
GetAdapterDisplayMode_Pointer typedef ptr GetAdapterDisplayMode_Proto
CheckDeviceType_Pointer typedef ptr CheckDeviceType_Proto
CheckDeviceFormat_Pointer typedef ptr CheckDeviceFormat_Proto
CheckDeviceMultiSampleType_Pointer typedef ptr CheckDeviceMultiSampleType_Proto
CheckDepthStencilMatch_Pointer typedef ptr CheckDepthStencilMatch_Proto
CheckDeviceFormatConversion_Pointer typedef ptr CheckDeviceFormatConversion_Proto
GetDeviceCaps_Pointer typedef ptr GetDeviceCaps_Proto
GetAdapterMonitor_Pointer typedef ptr GetAdapterMonitor_Proto
CreateDevice_Pointer typedef ptr CreateDevice_Proto


; END FUNCTION POINTERS ----------------------------------------------------------------------------

; IDirect3D9 INTERFACE DEFINITION

IDirect3D9 struct DWORD

IDirect3D9_QueryInterface QueryInterface_Pointer ?
IDirect3D9_AddRef AddRef_Pointer ?
IDirect3D9_Release Release_Pointer ?
IDirect3D9_RegisterSoftwareDevice RegisterSoftwareDevice_Pointer ?
IDirect3D9_GetAdapterCount GetAdapterCount_Pointer ?
IDirect3D9_GetAdapterIdentifier GetAdapterIdentifier_Pointer ?
IDirect3D9_GetAdapterModeCount GetAdapterModeCount_Pointer ?
IDirect3D9_EnumAdapterModes EnumAdapterModes_Pointer ?
IDirect3D9_GetAdapterDisplayMode GetAdapterDisplayMode_Pointer ?
IDirect3D9_CheckDeviceType CheckDeviceType_Pointer ?
IDirect3D9_CheckDeviceFormat CheckDeviceFormat_Pointer ?
IDirect3D9_CheckDeviceMultiSampleType CheckDeviceMultiSampleType_Pointer ?
IDirect3D9_CheckDepthStencilMatch CheckDepthStencilMatch_Pointer ?
IDirect3D9_CheckDeviceFormatConversion CheckDeviceFormatConversion_Pointer ?
IDirect3D9_GetDeviceCaps GetDeviceCaps_Pointer ?
IDirect3D9_GetAdapterMonitor GetAdapterMonitor_Pointer ?
IDirect3D9_CreateDevice CreateDevice_Pointer ?

IDirect3D9 ends



Thanks for any suggestions or comments.

...Sorry about the formatting, it looks correct the way I've copied it in, but in preview it is skewed.
Posted on 2003-05-30 14:08:14 by AlexEiffel
Try using the STDMETHOD macro - it makes life MUCH easier...
You don't need to define the IUnknown methods per se... take a look :)

DECLARE_INTERFACE <IDirect3D9A_>
; IUnknown methods
INHERIT_IUnknown
;additional methods
STDMETHOD <RegisterSoftwareDevice>,:DWORD
STDMETHOD <GetAdapterCount>
...

Note that using this method, you "chop off" the first dword parameter when defining the parameters for each Method, because that one is a pointer to "This" interface, and it's automagically added by our macro since its always there.

Also, you don't need to close the definition at all, but you do add a struct like this:
IDirect3D9A STRUCT
lpVtbl dword ?
IDirect3D9A ENDS

and some type definitions like this:
IDirect3D9 TYPEDEF IDirect3D9A
LPDIRECT3D9A TYPEDEF PTR IDirect3D9A
LPDIRECT3D9 TYPEDEF PTR IDirect3D9

and just incase you don't have the STDMETHOD macro,
STDMETHOD MACRO name,argl :VARARG
LOCAL @tmp_a
LOCAL @tmp_b
@tmp_a TYPEDEF PROTO argl
@tmp_b TYPEDEF PTR @tmp_a
name @tmp_b ?
ENDM

So that covers interfaces, and converting structs and equates is child's play.
Have fun :)
Posted on 2003-06-07 00:59:55 by Homer