Jump to content
  • Advertisement


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


QueryInterface or not?

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

I'm reading Tricks of the Windows... and in the DirectDraw section the author first creates a LPDIRECTDRAW object and then uses QueryInterface to get the LPDIRECTDRAW4 object. Now I was using that and all was fine but then I saw a tutorial on gamedev (http://www.gamedev.net/reference/articles/article1077.asp) where the author skipped the QueryInterface step and just created a LPDIRECTDRAW7 object from the start. Which method is the prefered way? Also with all these LPDIRECTDRAW4's and LPDIRECTDRAW7's flying around where do I go to see which interface is the newest one? [edited by - punx409 on January 22, 2003 12:09:21 AM]

Share this post

Link to post
Share on other sites
As I know there are 3 ways to get DirectDraw Object
// initialize COM

// create the object
CoCreateInstance(CLSID_DirectDraw, NULL, CLSCTX_ALL, IID_IDirectDraw7, (void**)&lpdd7);

// initialize the object

2)Using DirectDrawCreate to get IDirectDraw Object first and then using that object to query IDirectDraw object with version you like (say: IDirectDraw7)
// get the IDirectDraw interface pointer
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
// error-handling code here

// query for IDirectDraw7 pointer
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (void**)&lpdd7)))

// error-handling code here
// success! release IDirectDraw since we don''t need it anymore
lpdd = NULL;

3)Using DirectDrawCreateEx()

GUID FAR *lpGuid,
IUnknown FAR *pUnkOuter

you should use the 3th method because you can get DirectDraw Object just one call. Be sure to check if the function FAILED or SUCCESS using FAILED() and SUCCEED() macros.

Hope it help

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!