DirectX7 vs DirectX9

Hey Everyone:

I'm looking for a good book to teach me to develope a game with DirectDraw (2D platform), and have been searching for a good book...the only book I found with good reviews has been for DirectX7.  Could I use this book to help me develope for DirectX9 DirectDraw?  All id have to do is pretty much change the '7' in all the types to a '9' and then just include the ddraw.lib and ddraw.h to get it to complie and run, right?  Thanks

Who is Participating?
scervezaConnect With a Mentor Commented:
No, DirectX 7 is totally different than DirectX 9. That's the bad thing about DirectX. I have a DX7 game programming book and it's totally obsolete unless you want to use DX7 interfaces under DX9.

With DX8, DirectX went under a major reconstruction. The DX7 renderer was based on a blitter. The DX9 renderer is based on a scene render. Microsoft chucked the IDirectDraw7 interface replaced it with the IDirect3D9 interface, which is totally different.

For one, DX7 had Blt functions (for 2D and 3D rendering),
but DX9 does not. DX9 is more like OpenGL now with  BeginScene and EndScene functions:

// begin scene
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0, 0);
// do some rendering
// end scene
d3dDevice->Present(NULL, NULL, NULL, NULL);

In DX7, this is rendering code:

 // blt the surface to the screen
 // for both 2D and 3D cases
 result = primary->Blt(&destRect, offscreen, &rect, 0, NULL);

 if(result == DD_OK)
 if(result == DDERR_SURFACELOST)
    if(!RestoreAll()) return;

Now, if you want to program 2D games with DX9 it is very possible. All the blitting code was moved to the Direct3D Extension (D3DX) Libary. You use the D3DXCreateSprite function to draw 2D images onto the screen.

So i guess my answer to your question is... your DX7
book is obsolete.
fastawdtsiAuthor Commented:
How about DirectX8, could I use a DirectX8 book to build DirectX9 code?  Thanks

Yes, DX9 is pretty darn portable with DX8. As with every new DirectX release there are minor structure changes, minor function parameter changes, and new functions added. DX7 to DX8 was the last MAJOR structural change in DirectX. DX8 and DX9 share common interfaces and for the most part just replacing 8's with 9's won't generate too many errors, but you will get some depending with what you're working on. The concepts and interfaces between 8 and 9 are virtually the same.

Here is what Microsoft documents as the changes between 8 and 9:

Changes Between DX8.1 and DX9
BaseVertexIndex Changes
CreateImageSurface Changes
EnumAdapterModes Changes
Get/SetStreamSource Changes
Multisampling Quality Changes
ResourceManagerDiscardBytes Changes
SetSoftwareVertexProcessing Changes
Texture Sampler Changes
Vertex Declaration Changes
Vsync, Intervals, and SwapEffects Changes

As you can see these are not major structural changes. So yes, you can get by with a DX8 book and learn DX9. And the spots where there are changes, just look in the DX9 SDK help file. DX9 still uses FMVs, Vertex Buffers, and so on, and the concepts are the same between DX8 and DX9. However, DX7 is toooootallllly different (nasty long structures with multiple union members, different interfaces, different functions, and a smaller Direct3D Extension Library). DX8 and DX9 are really nice, and i've been using them. I started out with DX7 and all I can say is,"NAAAAAASTY!"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.