Jump to content

  • Log In with Google      Sign In   
  • Create Account


DirectX 7 and C / C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Alexander Deruwe   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 October 1999 - 02:50 AM

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


Sponsor:

#2 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 October 1999 - 12:01 PM

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


#3 Kentamanos   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 October 1999 - 12:10 PM

This is a COM requirement by the way. DX uses COM, so you have to do it that way.

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

-Kentamanos


#4 Dave Astle   Senior Staff   -  Reputation: 2307

Like
Likes
Like

Posted 26 October 1999 - 01:37 PM

To answer the last question, LaMothe uses DX6 in his latest book. He mentions DX7, but since it was still in beta while the book was being written, he doesn't get into details.

#5 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 October 1999 - 01:48 PM

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


#6 Alexander Deruwe   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 October 1999 - 08:01 PM

Thanks guys. You've cleared up quite a bit, and it is appreciated.

#7 NuFAN   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 October 1999 - 02:50 AM

Hi,
the lpVtbl means just something like "this", in C++, this is done automatically, but not in C.

CU

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS