Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++/DX11 Code Organization

Started by leonsbuddydave Sep 8, 2011 at 2:19 AM 3 replies 2.2k views
Original Post
leonsbuddydave
leonsbuddydave
I'd consider myself fairly intermediate level in C++, and I've been studying Direct3D to the point where I have a grasp on what I'm doing most of the time. My problem is that so far every time I try to make something with it (we're not talking big here; things like Pong, Tetris, learning projects) I get really caught up in how everything should be organized. I've read before multiple times that a good way to organize things is to keep graphics and logic completely separate, or organize the code into systems and subsystems and layers that work together, but I can't find any resources for learning how to do all this. Can anyone direct me to where I might find information regarding what I guess would be "game programming architecture"? Or if that's not really a commonly discussed thing, are there any good examples of small, recent Direct3D games that I can get and view the source of?

Thanks for reading, I've been struggling at this for a while and I'm kind of at a loss.
raicuandi
raicuandi
My suggestion is start really basic and then refactor, that's one -dare I say natural- way to learn it. On my tetris clone I had everything as globals at first, then started to separate as I built the game.
saracen
saracen
I can see maybe a few ways you can go about learning what you need to know:

1. game programming books
Many of these books introduce beginning programmers to game programming. They provide a good primer on basic game architecture/constructs like the game loop, game networking, sound/audio management, user interface, game concurrency/thread management, etc. If you want a basic intro (looks to me like this is what you want now), this is a good way to quickly learn what you need.

2. read source code
The 1st suggestion above gives you only the most rudimentary intro to game architecture that works for simpler games. For "real world" game design/architecture that solves some really challenging problems with distributed players, huge worlds, dead-reckoning, etc, you should go dig into source code.

http://doom.wikia.com/wiki/Doom_source_code
http://www.shacknews.com/file/7443/quake-3-132-source-code

Alot of these are in C/C++ so looking at the header files will be a good place to start.

There are obviously alot more open sourced code lying around. But these are the 2 I actually dug into. Admittedly they are abit archaic by now.

3. read forums
There are quite a bit of discussion on specific stuff like game networking, texture management, world creation, on gamedev itself, as well as other blogs/portals. Go Google them.
Slavik81
Slavik81
Plan to throw one away. You will anyway.

Just get it done the first time. You'll have a better understanding of what's required and how your design could be improved the second or third time you iterate on it..

Trying to organize your systems logically before you understand them is bound to end in failure.
leonsbuddydave
leonsbuddydave
You guys are awesome, that's all the most useful information I've gotten on this subject. Especially thanks for the source code links; it's been difficult to find well-documented source to learn from. I've started smashing together an improvised pong clone (so far it's the least organized thing I've ever made, everything global and public) but it's coming along rapidly and I'm learning a lot. Thank you!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.