views:

335

answers:

6

I'm a C# developer for the most part. Back in college I had classes on C/C++ so I "know C" and that's a good chunk of the reason I'm a C# developer.

However I've never had the chance to code in C/C++ professionally and I'd like to study how a modern game engine works, along with how an industrial grade C/C++ app operates.

The problem is, I have no idea where to start. As in, I downloaded the Quake 3 engine source code (which has been retronymed id Tech 3) and I'm not even sure where to start with it.

How should a sheltered C#/WinForms attack a massive C codebase like id Tech 3 or some other massive AAA engine?

+10  A: 

Try to do the simplest 3d "Hello World" program that uses the most basic subset of the engine. That will probably teach you loads.

With big code bases it's best not to try to learn everything all at once. Just dive in with a very specific question that you need to answer to yourself (or can search for on the internet), or a very specific task that you need to accomplish. This approach gives you the purpose and motivation you need to actually do some programming. The learning will come by itself.

Inshallah
+1 Absolutely - just like the first day on a new coding job, the best thing is to jump in and start fixing bugs - you soon find out everything you need to know.
Justicle
+4  A: 

Writing a mod would be a good starting point.

Start on charted territory: The vanilla game. Change stuff. Look at the grenade bounce code. Make it bounce further. Add client-side prediction (which non-bouncy projectiles already have).

Add a teleport weapon. It will tell you more about collision detection than you'd like to know.

There are a few key functions that handle most of the game: The engine exports, the trap_* calls. It might help a great deal to know what exactly mods are doing with them before opening up the engine code and looking at their implementation.

For example, it might tell you more about the engine to know that you need to call LinkEntity every time an entity moves or otherwise its position in the game BSP tree is not updated and subsequent engine calls might ignore it, than to know exactly how the tree is stored and accessed.

aib
+1  A: 

Just in case you're looking for other 3D game engines and may perhaps want to compare them with each other, see dim3:

http://code.google.com/p/dim3/

+3  A: 

This sounds like a joke, but: find the main() function. That's the well-defined starting point of the program's execution, and you should be able to follow everything from there.

This should help you figure out which subsystems depend on which, since the order of their initialization will typically be bottom-up. For instance, a typical engine will initialize its memory, debugging and tracing subsystems early, since most other systems need those services to be up and running.

You should also be able to figure out the way into the game's main loop, and understand what is needed before the loop gets control.

unwind
This ties into my lack of experience with Windows C++ programs - I've found the WinMain function but it's unclear how it does anything. I guess it's time to start stepping through...
Schnapple
+1  A: 

Andre LaMothe pretty much taught me everything I know about game programming. Once you get through these two books, you'll pretty much know everything you need to know about 3d engines.

  1. Tricks of the Windows Game Programming Gurus
  2. Tricks of the 3D Game Programming Gurus - Advanced 3D Graphics and Rasterization

Otherwise, just try writing your own little engine for fun, see how far you get, what you're missing, and you'll soon start to understand the purpose of the other code you're looking at,

Also might want to try looking at the NeHe Gamedev Tutorials.

ReaperUnreal
A: 

I have never been a big fan of reading a large finished product. And especially the Quake code base. There are good thing you can learn from it for sure but it shouldn't be your starting point. You need to learn first some new concepts used in game programing.

I'll suggest to put C++ a bit on hold (if you want to make game you really need to go back to it at some point) but for now install XNA. It's as great Framework as everything .NET. THere are plenty of tutorials about game XNA out there.

Aleks