RE: [Algorithms] Introducing COM into existing engine
Brought to you by:
vexxed72
From: Tony C. <to...@mi...> - 2001-01-02 11:47:24
|
>I just ported my little engine to DirectX8 and thought about converting it >into a dll (right now you have to include the source) but it seems to make >a lot of sense to implement it as COM objects. The thing I like most about >COM objects is that you only need to distribute one dll and an interface >definition file, whereas with an ordinary dll I would have to distribute >the dll plus all headers in the project (since they all include each other >somewhere). That seems like a reasonable approach. It also gives you the advantage of being easier to migrate to other languages (e.g. VB or C# for writing tools) should you wish to do so in the future. >However, I'm not certain which objects should become COM objects. Of >course I would only want to expose some interface functionality, and I >would likely hide stuff like CRenderstateNode. But I'm not sure about >which level of abstraction would be usefull. My engine class is probably a >good COM candidate. Maybe the camera too. But what about my vector class? >I don't think it would make a good COM object, but it would be nice if the >client code could use calls like someObject.InitPosition(CMyVector(0, 0, >0)); Tiny little data objects like individual vectors are not good candidates for COM objects. COM is less fine-grained than that - think of supplying *components* rather than individual data objects. >As you may have guessed, I'm not too familiar with COM, so here is another >question: would you recommend to use ATL or should I write everything >myself? If you're not too familiar with COM, you could do a lot worse than read Don Box's "Essential COM", which is pretty much *the* book on the subject. To answer your specific question, ATL is great, although it can take a little bit of getting used to. Certainly there's no real reason to endlessly rewrite boilerplate code for class factories, IUnknown implementations and free-threaded marshaller aggregation when then ATL just does it all for you. Tony Cox - DirectX Luminary Windows Gaming Developer Relations Group http://msdn.microsoft.com/directx |