Jump to content
  • Advertisement
Sign in to follow this  
Calin

Component Object Model?

This topic is 4841 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

One week ago I started learning DirectX. I have some OpenGL experience so I hacked a way to put some piramids on the screen and make them move/rotate. The problem is that after more than a week I still find it very difficult to understand the DirectX code written by others ( like DX sample code etc.) The thing that gives the most headache is Component Object Model and the need to use an Object Interface. Why can`t you just declare a D3D object and then use that object and his functions the regular way ( e.g. DIRECT3D9 InstanceD3D; InstanceD3D.Draw() or InstanceD3D.Translate() etc.) Can anyone bring some light? [Edited by - Calin on August 15, 2005 2:21:01 PM]

Share this post


Link to post
Share on other sites
Advertisement
You can't declare COM objects by value because you don't have access to the implementation. All you have is a declaration of the interface, which is an abstract base class.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
You can't declare COM objects by value because you don't have access to the implementation. All you have is a declaration of the interface, which is an abstract base class.


Seems like I`ll have to go back to those inheritance and polymorphism lessons again.

Share this post


Link to post
Share on other sites
More specifically, the use of the Component Object Model in DirectX is a design decision to enabled seamless backward compatibility in future versions of the SDK/runtime. Each DirectX runtime version includes all previous definitions of the interface, each with its associated methods and capabilities. Rather than creating a situation in which different applications will require the end user to install different versions of the runtime (because that's what they're written to), using COM allows the end user to always install the latest version and still have the oldest DirectX 5 application run unchanged.

In your code, when you write something like LPDIRECT3D9 * pD3D9 = CreateDirect3D9(D3D_SDK_VERSION);, you are employing several layers of abstraction via the helper routines in the SDK to minimize complexity. Were you to actually dispense of all that assistance and go "pedal to the metal," you would need to:
  1. Initialize COM (call CoInitialize with the appropriate parameters) for your application.

  2. Retrieve a pointer to an IUnknown interface.

  3. Query this IUnknown for an IDirect3D interface, which you will then query for available version numbers in order to retrieve an IDirect3Dx interface, where the x represents your desired - and available - version number.

  4. Specify the appropriate inproc/out-of-proc and other server settings.

  5. Prep the interface for use in querying for other Direct3D objects - device, vertex buffer, index buffer etc.


While it all seems very complicated (and, actually, it is), it's an incredibly robust system, particularly in conjunction with Windows' support for side-by-side component versioning since Windows 98 SE. Fortunately, you don't have to deal with all that. Just use the extremely handy functions delivered in the SDK!

Aren't you glad you really don't need to know all of that?

Share this post


Link to post
Share on other sites
Thanks Oluseyi, that makes things more bearable (not much though). I guess I`ll have to take things as they are and move further. Thanks again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!