• Advertisement

Archived

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

DirectX 7 and C / C++

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

Well, the first thing to know is that when calling DX functions in C, you have to pass the pointer to the object as the first parameter. Taken from the MSDN library:

C code:
ret = lpDD->lpVtbl->CreateSurface (lpDD, &ddsd, &lpDDS, NULL);

C++ code:
ret = lpDD->CreateSurface(&ddsd, &lpDDS, NULL)

Anyway, hope that helps.

- Splat

Share this post


Link to post
Share on other sites
Advertisement
This is a COM requirement by the way. DX uses COM, so you have to do it that way.

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

-Kentamanos

Share this post


Link to post
Share on other sites
In fact, if you did manage to use C++ classes in pure C code, this annoying requirement of putting the object pointer as the first entry would still apply (since in C++ the first parameter to any member function is, although not explicited defined by you, the "this" pointer)

- Splat

Share this post


Link to post
Share on other sites
When I write a C++ program that uses DirectDraw, all goes OK.
When I later on write the exact same program in C (IE: Just change the extenstion), I get tons of errors on DirectX, though the code seems correct for C also (it's procedural, I don't use classes).
Does anyone know why? What do I have to do to make my game in C (I like C better.

Secondly, what version of DirectX is featured in Andre Lamothe's latest book?

/Alex

Share this post


Link to post
Share on other sites
Hi,
the lpVtbl means just something like "this", in C++, this is done automatically, but not in C.

CU

------------------
Skullpture Entertainment
#40842461

Share this post


Link to post
Share on other sites

  • Advertisement