Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

julienX

new to dx - COM stuff?

This topic is 5741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey im reading TOTWGPG and am up to the directx primer which talks about COM. I don''t get a single word of it! Well i''m gonna go over it another few times, but I just wunna know if making ya own COM classes/objects and stuff is actually something you would need to do to make a game in dx. I guess u dont NEED to but then what is it for then? (COM) Sorry but im just a newb ta dx Thanks for ya time!

Share this post


Link to post
Share on other sites
Advertisement
COM is for making components. This are libraries that other programs then use. COM can be utilised in various ways, and most hav to do with architecture - making a program not only working, but also easy to maintain.

Besides, COM+ (a com extension, so to say) offers a lot of support for enterprise projects - security (not everyone can call every method), distributed transaction support etc.

All of this is pretty useless if you stick around with simple things like simple games - it CAN turn very usefull on a MMORPG backend. Depends on the level of professionalism of the developers.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Thanks for the reply, but if you say:

"All of this is pretty useless if you stick around with simple things like simple games"

Then why does it explain how to create COM classes ect in
the book (TOTWGPG)?? Ain't it supposed to be for beginners?

Thanks

I'm guessing that it explains it so you are aware of it, and just in case you need to use it. Is this right?



[edited by - julienX on February 1, 2003 9:39:57 AM]

Share this post


Link to post
Share on other sites
I think the section on COM is just there for those of us that need to know something inside and out before we understand how to use it. You should be able to use COM objects even if you don''t understand how they work, but I personally find it helps if I can visualise what''s going on behind the scenes.

Share this post


Link to post
Share on other sites
Krunk, thats pretty much the point :-). It is there for people interested in getting more stuff, I would agree on this.

BTW - if anyone ever wants to make COM classes, get VS.NET and a good book on ATL 7. They made marvelous things with attributes and aspect like programming :-) Takes out all the terrible things from COM programming, and no more IDL management (as the IDL is generated from the annotated C++ file).


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Just ignore the com stuff and continue, dont get held up on it.

DirectX uses COM inside its functions, but you wont see it programming with the DirectX .H and .LIB''s from the SDK. So just move on and continue with the book.

------------------------------------------------------------

But to answer your question, normally a DLL can contain all kinds of functions with parameters. COM is a design that is supposed to help mismatches in case the DLL''s change functions and parameters so old code can still run. They accomplish this by having 1 function in a DLL "query interface" (Interface is just another name for function names and parameters at a given time, everytime functions are renamed/added/deleted, or the parameters, a new interface is created). If the code was programmed with an older interface, COM will give the older interface, while new code will use the newest interface... As you can see with DirectX, this is exactly how old applications written for DirectX5 can still run with DirectX9 runtime libraries. Because the COM is giving it an "older interface" to run with so it acts like DirectX5 when it indeed isnt. Its really easy in concept yet complex in practice. But you won''t have to worry about this, since the headers and librarys in the DirectX SDK do the COM junk "behinds the scenes" for you.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
to me com interfaces appear no different than a c++ class.
if you know how to use classes then you can use DirectX.

Share this post


Link to post
Share on other sites
To continue a little from JoeyBlow2:

- older versions of DirectX (before 7) required a lot more use of COM - for example in DirectDraw you''d create a IDirectDraw interface then be required to QueryInterface() from that if you wanted anything newer, the use of GUIDs to specify which object you were talking about was everywhere. I''d expect that''d be quite confusing if a book didn''t explain WHY it was necessary.

And if you ever wanted to use ActiveMovie (which later got re-written and became DirectShow), its API was heavily reliant on people knowing COM.

COM itself is pretty simple, but its boundaries aren''t so clear these days - the boundaries with ActiveX* and OLE have become blurred (COM is really just the base which sits under the others, and ActiveX now encompases OLE - all far more complicated than it once was - bring back OpenDoc )


All that said, it isn''t at all important to know for DirectX - particularly version 8 or above. The stuff mentioned by the above posters is about all you NEED to know about the connection between COM and DirectX*.

[* just jogged my memory - I wonder if X is still officially silent ]


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
quote:
Original post by S1CA
...older versions of DirectX (before 7) required a lot more use of COM - for example in DirectDraw you''d create a IDirectDraw interface then be required to QueryInterface() from that if you wanted anything newer, the use of GUIDs to specify which object you were talking about was everywhere.

All that said, it isn''t at all important to know for DirectX - particularly version 8 or above.


Just to go slightly offtopic for a moment, is there any particular reason why the GUIDs for D3D8 (and presumably D3D9) are hidden away? It''s really annoying because I use a COM smart pointer, so being forced to call the "helper" function makes my code more complicated. I can understand that the DX team would want to provide an easy way to get at IDirect3D, but why prevent the use of CoCreateInstance? Even if I had to call an "initialise" method before using the interface (like in DirectInput, DirectSound), it would be nice to have the option.

Share this post


Link to post
Share on other sites
Krunk:

Unfortunately I''ve no idea - I suspect MS surveyed the comments and complaints from any developers who contacted them and those on the beta programmes - many people hated having to jump through so many hoops of COM stuff just to be able to do something like create a device.

I know that when DX8 was introduced, at Meltdown MS were very chuffed at how much simpler the setup of a D3D device was. Personally I preferred it too.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!