Question about c,c++,direct x and game development

Started by
18 comments, last by _the_phantom_ 14 years, 3 months ago
In the creation of a game i see most developers use c++. I just have a few questions that need answering 1)I see WoW uses the C Language and direct x graphics. I thought direct X couldnt be used in C so how would they go about doing this? 2) In directX programming is there a tutorial/way to use normal C++ with the Win32 part of the programming?
Advertisement
I think you have a few confusions about what Direct X and Win32 is exactly.

DirectX is basically just some libraries that serve as an intermediary between your code, and the hardware. Back in the day the games had to have special code for all different types of hardware, there was no abstraction so if the game didn't directly support some kind of hardware, you were SOL. DirectX came, and provided one interface to access any different kind of hardware, and if the hardware didn't support something then it could tell you, and possibly try and emulate the functionality with software.

Win32 is another library, and it allows your application to interact with the windows operating system. This entails things like making windows, receiving messages, etc...

Now for your questions:

1) I'm wager that WoW uses C++. Any large project nowadays is going to be using object oriented programming, it's just too essential to creating manageable software. DirectX is built on COM, which requires C++, so you could not use it with C, I believe. Keep in mind though, that C++ is pretty backwards compatible with C, so you could write and compile C code with a C++ compiler, and use C++ libraries with your C code.

2) Win32 and DirectX are "normal C++". They are just libraries, they can be accessed by any language. Visual Basic, Delphi, Python, Etc... can all use Win32 and DirectX. Not sure exactly what you're asking here.
Quote:Original post by cclyde
DirectX is built on COM, which requires C++, so you could not use it with C, I believe.


No, COM can be used with C. That's why the header files are built with all those mental macros. You basically end up calling free functions and passing the equivalent of this as a normal parameter.

It's awkward but it can be done.
COM can be used from many many languages as that it pretty much its reason for existing; it can be called from C++, C, VB and .Net languages for example.
Quote:Original post by cclyde
Win32 and DirectX are "normal C++". They are just libraries, they can be accessed by any language. Visual Basic, Delphi, Python, Etc... can all use Win32 and DirectX. Not sure exactly what you're asking here.


Actually, it is extremely difficult to get DirectX to work with older Borland Win32 compilers. I'm not entirely sure why this is but this was what made me migrate from Borland to Visual C++.

And yes, you can mix C and C++ code very easily. You might have to typecast certain data and at worst wrap some code in "extern C" but they are very compatible. In fact, I mostly use standard C with C++ only being used for the class portion.
Quote:Original post by cclydeyou could ... use C++ libraries with your C code.


Um, maybe you mean use C libraries with C++ code?
Quote:Original post by harminal
In the creation of a game i see most developers use c++. I just have a few questions that need answering

1)I see WoW uses the C Language and direct x graphics. I thought direct X couldnt be used in C so how would they go about doing this?

2) In directX programming is there a tutorial/way to use normal C++ with the Win32 part of the programming?


World of Warcraft is written in C++, not C.
Quote:Original post by Flimflam
Quote:Original post by harminal
In the creation of a game i see most developers use c++. I just have a few questions that need answering

1)I see WoW uses the C Language and direct x graphics. I thought direct X couldnt be used in C so how would they go about doing this?

2) In directX programming is there a tutorial/way to use normal C++ with the Win32 part of the programming?


World of Warcraft is written in C++, not C.


C++ is just a superset of C. I wouldn't read to much into semantics. I know of no commercial compilers this day and age that are exclusively C or exclusively C++. Every modern compiler I've seen has supported both and often support ASM too.
Its not semantics because they are two different languages (which is why I cringe when someone says C/C++) and really should be treated as such.

C is C, C++ is C++. Compilers might well deal with both however that doesn't make them the same thing and it disappoints me that people working in a field which requires precision and correctness ignore this simple fact.

If anything, this mixing of C and C++ is probably partly to blame for so much bad C++ existing because people treat C++ as 'C with classes' and end up writing bad code and missing out on the many features of C++ which would allow them to write better programs; both in code quality and execution speed.

So, yes, the semantics are important.

(also, while there might well be support for C89, C99 is alot less widespread. Afaik VC++ doesn't support it even in VS 2010)
Quote:Original post by phantom
Its not semantics because they are two different languages (which is why I cringe when someone says C/C++) and really should be treated as such.

C is C, C++ is C++. Compilers might well deal with both however that doesn't make them the same thing and it disappoints me that people working in a field which requires precision and correctness ignore this simple fact.

If anything, this mixing of C and C++ is probably partly to blame for so much bad C++ existing because people treat C++ as 'C with classes' and end up writing bad code and missing out on the many features of C++ which would allow them to write better programs; both in code quality and execution speed.

So, yes, the semantics are important.

(also, while there might well be support for C89, C99 is alot less widespread. Afaik VC++ doesn't support it even in VS 2010)

Well I know VS2008 had poor to nonexistent C99 support from the little bit I tried to use.

[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

This topic is closed to new replies.

Advertisement