To share or not to share…

So, I’m gradually working towards making a simple fighting game, using my Kinect as the input sensor. I think initially it’ll be one person punching a punching bag, then two people competing, and then probably some sort of computer controlled AI which looks at your pose, and chooses the right pose/move accordingly (although since I don’t really know how to fight, that will be interesting).

The Experiment

Anyhow, a few weeks ago I got a very rudimentary scripting host working, where I have my rendering infrastructure written in C++, and I have a mono .NET window displaying the output etc. Well I have since improved it to allow me to create entities on-screen in a (somewhat) adhoc manner (they’re all the same entity at the moment). In doing this I decided to do an experiment to discover what we all know is true: if you have more than one instance of the same model on screen, it better be the same vertices et al in memory. My Naive version loaded the model from disk, and packed it into my renderable format in memory each time the scrip requested an entity from the engine. I wanted to do 1000 entities, but the Naive approach crashed my computer at ~380, so for my performance comparisons I only went up to 200. My second approach uses boost::flyweights to share the model amongst all the entities that use it. I performance tested this one up to 200 as well, but as you can see below it gets up to 1000 dwarves on screen quite happily.

Snow-white couldn’t cook for all these guys.

Continue reading “To share or not to share…”

Learning DirectX and C++: Step 3, Timing and Text

I’ve pondered, for a while, on the merits of me writing out every lesson I learn on my journey to become a game programmer, and I think that the HOWTO format is not going to be sustainable. So, from now on I’ll be jotting down some notes, and some key points, but I’ll be dispensing with full code listings and blow-by-blow coverage of what’s going on.

So, on to timers and clocks in DirectX.

Continue reading “Learning DirectX and C++: Step 3, Timing and Text”

Learning DirectX and C++: Step 2, Initialise DirectX

In order to make the most simple use of DirectX we must set up the required infrastructure. This is as follows:

  • A swap chain (at least two areas of memory, one for drawing into, one for displaying to the screen).
  • A RenderTargetView (a reference to the area of memory from the swap chain for drawing into).
  • A Depth/Stencil buffer, and a view onto it. (Used to help decided whether any given pixel should be drawn).
  • Bind the RT (RenderTarget) and Depth/Stencil views to an Output Merger stage.
  • Set the Viewport (a sub-rectangle of the BackBuffer that we will draw to).

Naturally after we have set up this infrastructure we have repeatedly draw some sort of scene; we will get to that after we have discussed the topics above.

Continue reading “Learning DirectX and C++: Step 2, Initialise DirectX”