DirectX 7 and C / C++

Started by
5 comments, last by Alexander Deruwe 24 years, 5 months ago
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

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

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

-Kentamanos

-Kentamanos
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.
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

Thanks guys. You've cleared up quite a bit, and it is appreciated.
/Alexander Deruwe
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

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

CU

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

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de

This topic is closed to new replies.

Advertisement