Using COM Objects from Max

BlitzMax Forums/BlitzMax Programming/Using COM Objects from Max


Mark, I saw an earlier post from you where you were calling DirectX9 (for some new stuff that is coming). How were you able to do that? DX9 is based on COM



I've 'tweaked' the compiler so that you can use 'native' C++ objects from within Max, like this:

Extern "Win32"
Type IUnknown
   Method QueryInterface()
   Method AddRef()
   Method Release()
End Type
Type IDirect3D9 Extends IUnknown
  Method Blah()
  Method Etc()
End Type
End Extern


There are some limitations: You can't 'New' such 'extern objects' - this must be done by somewhere else by non-Max code, and of course they're not managed for you. They can't extend normal Blitz Types, and vice versa.

COM objects are really simplified C++ objects, so this is enough to be able to access DirectX pretty cleanly. I haven't looked into the 'CoCreateInstance' stuff, as DirectX functions do this for you, but I don't think that would be a huge headache.

As far as I know, OLE/ActiveX and all that crud is built on top of COM and CoCreate etc, but its not something I'll be spending any time on.