TAILIEUCHUNG - Character Animation with Direct3D- P3

Character Animation with Direct3D- P3:This book is primarily aimed at teaching indie and hobby game developers how to create character animation with Direct3D. Also, the seasoned professional game developer may find some interesting things in this book. You will need a solid understanding of the C++ programming language as well as general object-oriented programming skills. | 26 Character Animation with Direct3D if g_pDevice NULL Could not create the Direct3D Device exit. Release IDirect3D9 interface you don t need it anymore d3d9- Release This code will set up a Direct3D device assuming that you have a graphics card that supports hardware rasterization hardware vertex processing the selected back buffer format etc. I also store the finished Device as a global pointer so it can be accessible from classes other than the Application class. The Device output is now connected to the window created earlier. So if you wanted to clear the background of the window to a certain color you could use the following code Clear the viewport g_pDevice- Clear 0 NULL D3DCLEAR_TARGET Oxffffffff 0 Num rectangles to clear Rectangles to clear NULL whole screen Clear Color Clear Clear the render target AARRGGBB in this case White Z-buffer to Stencil Buffer to 0 Direct3D Rendering Loop The rendering loop of Direct3D is quite simple and is governed by three functions BeginScene EndScene and Present . Between the BeginScene and EndScene functions is where you can do your rendering drawing and once done you call the Present function to show the result to the screen. The Present function automatically takes care of the back buffer swapping etc. so you don t have to worry about that. Clear the viewport g_pDevice- Clear . Begin the scene if SUCCEEDED g_pDevice- BeginScene Do your rendering here lease purchase PDF Split-Merge on to remove this watermark. Chapter 2 A Direct3D Primer 27 End the scene. g_pDevice- EndScene Present the result g_pDevice- Present 0 0 0 0 Passing zeros to all the Present functions parameters displays the result to the entire window full screen that is which is what you d want. For more info see the DirectX SDK documentation. This has been a lot of initialization code to take in now. Just stay with me a little while longer and you ll have something actually showing on the screen. Loading a Mesh In this chapter I ll .