Thursday, 3 March 2011

Things I have learnt recently...

Since I've been programming DirectX 10 a lot recently, here are a couple of quirks and gotchas that I've found (and lost a fair few hours to).

1.  Never, and I mean, never, accidentally use a DirectX 10 buffer initialised with vertex buffer binding flags as an index buffer.  If it just returned an error code/threw an error, like most other similar things in DX, then this would be simple to spot/fix.  However, what actually happens is that it assigns fine AND renders fine, but screws up the DirectX state is a way that will cause a horrible memory error at a later arbitrary time. 
2.  Be careful with input layouts - even with matched annotations it seems there is no proper checking that the size of each annotated variable is assured to be identical.  As a result, you could have a variable Pos that you've specified as a float3 in a vertex shader input structure, while in the layout it's defined as a float4, and no error will be flagged.  It may even render reasonably, but will probably be doing bad things to the DirectX state.

At the moment I'm splitting my time between tools work (on the main map editor) and working on the ship editing overlay.

This image shows a small world map in the editor with the navigation nodes for the AI ships added.  Each node has a radius as well as a position/connectivity information to provide additional information on free space around the ship.

No comments:

Post a Comment