Jump to content
  • Advertisement
Sign in to follow this  
Simpsons4261

How can c++ end up creating these great games?

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

It doesn't seem like C++ would be able to make all these great games, and great applications. Granted I haven't really learned it yet, but I don't see how this coding could make games, or applications out of just this little DOS window. Anyone care to explain?

Share this post


Link to post
Share on other sites
Advertisement
Games aren't written to run in a little DOS window. C++ can make a computer do anything that a computer is capable of doing... you just need to know how to write the low-level code, or have access to the correct high-level libraries. I don't think that your question can be sufficiently answered for you until you learn C++. Once you know and understand the language, it will make more sense.

You could look around at the NeHe tutorials to see what some simply OpenGL graphics stuff looks like in C++. (Note: the NeHe tutorials are not recommended, it seems, for actually learning OpenGL.)

Share this post


Link to post
Share on other sites
Standard ANSI C++ cannot, however using (or developing)
system APIs or graphical APIs, you can.

Most large applications, for example, use their system API,
such as the Win32 API, to access system recources--including
input, sound, and basic graphics.

Large games are based around (useually in house) game engines
that have there own software renderer and interfaces to graphical APIs,
such as DirectX and OpenGL.

Alot of games use a C++ with DirectX and OpenGL.

I second NeHe. I personally don't have anything against his tutorials,
just the coding practices in his tutorials. This is just my opinion,
though[smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Simpsons4261
It doesn't seem like C++ would be able to make all these great games, and great applications. Granted I haven't really learned it yet, but I don't see how this coding could make games, or applications out of just this little DOS window. Anyone care to explain?


Hehe, I know what you mean, cos I used to wonder the same thing. It's a fair question, and the answer is:
No, you're absolutely right. C++ can't tell your graphics card to draw a man with a gun. It also can't tell the sound card to play your .wav file.
C++ specifies only what the CPU should do. So technically, it can't even create a little black dos window. Because that requires the GPU and other components to cooperate.

But since that obviously happens when you run your the program you wrote, there must be more to it, right? [wink]

The answer is that other code, written by other people, can do all these things.
Microsoft has written tons of code in the Windows API that, among other things, is able to create a little black box. Somewhere deep down in all that code, is some assembly code that performs little bit of very hardware-specific magic, which causes the graphics card to draw things. In this case a black dos window, but in principle, it might as well be your 20 polygon fighter jet, with fancy shaders everywhere.

They then take this bit of assembly, and wrap it up in a nice C (or C++) interface, with regular functions you can call from your C++ program.
So while C++ itself can't do any of these things, it's fairly good at calling functions defined elsewhere. And that "elsewhere" code is able to do all the magic, because it might not be written in C++.

Essentially, that's what NVidia's driver team is doing. They do all the hardware-specific low-level programming, presenting a nice C interface to the OS. And then Microsoft can take this interface, and plug it into Direct3D, which also has nice C++ functions you can call. And then you can, simply by using C++ to call code written by these other companies, make stuff appear on the screen, or sound to be played. Or data to be written to the harddrive, even.

Share this post


Link to post
Share on other sites
You are sitting at the top of many layers of abstraction. Generally, you have:
You-->Compiler with libraries-->a wide assortment of lower level languages-                                                                                 |
Electricity<--Transistors<--CPU/Memory<--assembly-/



So if you want to go down that rabbit hole, you can either start at the bottom and work up, start at the top and work down, or try and eat both ends at once. This will give you the greatest understanding of how computers do what they do.

Edit by JWalsh: Please use source tags when using so many spaces, code tags cause the table format to get screwed up and the forum looks odd. Thanks.

[Edited by - JWalsh on July 25, 2007 7:46:30 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!