   upgrading my app from dx8.1 to dx9(Dec12, 05)
  HelloI am wondering if anybody here can give me some advice on upgrading my game to DX9 from DX8.1.  First time I have done this kind of thing...I found migrating from vc6++ to vc7++ quite traumatic.  It is fairly large(10,000 - 20,000 lines) and I am not quite sure what the best approach is...I am currently reading the "Converting to Direct3D 9" from the SDK help file to familiarise myself with the changes in terms of function calls etc.  I am also wondering what other considerations the are in terms of 'include' files within my project....is it simply a case of trawling through my source files looking for "***dx8***.h" files and replacing with the "***dx9***.h" equivalent.Thanks in advance for your help   :)   
  The easiest way, which is ugly...In your precompiled header, include d3d9.h instead of d3d8.h, and d3dx8.h to d3dx9.hNext, still in your PCH, put in typedefstypedef D3DLIGHT9 D3DLIGHT8typedef D3DVIEWPORT9 D3DVIEWPORT8typedef LPDIRECT3DTEXTURE9 LPDIRECT3DTEXTURE8...Change your calls to SetIndices to the new method (basevertexindex was moved to DrawIndexedPrimitive).If you use stateblocks and shaders, switch to the new code where instead of a DWORD you have a LPDIRECT3DSTATEBLOCK9 and LPDIRECT3DVERTEXSHADER9, etc.Change calls to SetVertexShader to SetFVF where you're not setting a shader.Change shaders decls to vertexelement9, create a LPDIRECT3DVERTEXDECLARATION9 from them, and use them in SetVertexDeclaration rather than SetFVF/SetVertexShader.Change your shaders to declare their inputs.  Your code no longer needs to worry about which inputs go to which registers, they bound by type (shader says I want position in V0, and that's where it goes).Compile.Many functions will have the wrong number of parameters.  Most of these will be a "sharedhandle" tacked onto the end.  Just pass an extra 0 for these.Compile again.Fix remaining problems.  (I think I covered most of the problems that will come up, but I likely missed several);  You might be able to do a global search for "8" in your code. A large number of the results found should be DX-related and just replace them with 9.I can't talk about shaders and the other thing is the extra parameter; for this I reckon compiling and fixing the errors is easiest. Unless you have all your DX stuff encapsulated in some nice base classes of course...I'm not looking forward to migrating 8.1->9x either. The D3D base code is about the oldest code I own, follwed by my rendering code - so they are by far the worst-written classes which makes 'porting' more difficult. I'll probably rewrite by whole D3D section from scratch when I decide I NEED shaders.   ;I've done DX-version upgrading several times already (DX7 -> DX8 -> DX9) and eventually I have found out that it was always a good thing to do. I suggest using/taking advantage of the DXUT which comes with the latest DX9 SDK, it'll save a lot of work.Also as somebody pointed out, writing a clear class for the D3D part will save a lot of headache (and make future upgrades simpler). I have managed to separate the game part from any D3D related stuff.   ;  how will DXUT help me please?as for having a "direct3D" section in my game there is not....I would guess that there is DirectX calls in almost all of my source files.....any tips for segregating?The 2 biggest messes I have run into so far are shaders and state blocks.  My code relies on CaptureStateBlock() but I see they dropped it in DirectX9.  Capture() has a different effect.  I need to be able to preserve a current state, do some rendering using a different state then restore.  As far as I can see from the documentation I will now have to:CreateStateBlock(&pSavedStateBlock), do some rendering using a different state then restore, then release the state block interface just created...is the best way to approach this situation now?   